defining webapp load order in jetty -
i have 2 webapps might deployed separately or in same jetty server. in situation, 1 webapp must deploy before other can complete deployment, i'm looking solution in dual deployment case can define deployment order.
i've defined context xml file following:
<?xml version="1.0" encoding="iso-8859-1"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure.dtd"> <configure class="org.eclipse.jetty.server.handler.handlerlist"> <new class="org.eclipse.jetty.server.handler.handlerlist"> <set name="handlers"> <array type="org.eclipse.jetty.server.handler"> <item> <new class="org.eclipse.jetty.webapp.webappcontext"> <set name="contextpath">/security</set> <set name="war"><systemproperty name="jetty.home"/>/security_app/war/</set> <call name="addaliascheck"> <arg> <new class="org.eclipse.jetty.server.handler.contexthandler$approvepathprefixaliases"/> </arg> </call> </new> </item> <item> <new class="org.eclipse.jetty.webapp.webappcontext"> <set name="contextpath">/</set> <set name="war"><systemproperty name="jetty.home"/>/main_app/war/</set> <call name="addaliascheck"> <arg> <new class="org.eclipse.jetty.server.handler.contexthandler$approvepathprefixaliases"/> </arg> </call> </new> </item> </array> </set> </new> </configure> however, solution, following error:
java.lang.classcastexception: org.eclipse.jetty.server.handler.handlerlist cannot cast org.eclipse.jetty.server.handler.contexthandler @ org.eclipse.jetty.deploy.providers.webappprovider.createcontexthandler(webappprovider.java:292) @ org.eclipse.jetty.deploy.app.getcontexthandler(app.java:101) @ org.eclipse.jetty.deploy.bindings.standarddeployer.processbinding(standarddeployer.java:36) @ org.eclipse.jetty.deploy.applifecycle.runbindings(applifecycle.java:186) @ org.eclipse.jetty.deploy.deploymentmanager.requestappgoal(deploymentmanager.java:498) @ org.eclipse.jetty.deploy.deploymentmanager.addapp(deploymentmanager.java:146) @ org.eclipse.jetty.deploy.providers.scanningappprovider.fileadded(scanningappprovider.java:180) @ org.eclipse.jetty.deploy.providers.scanningappprovider$1.fileadded(scanningappprovider.java:64) @ org.eclipse.jetty.util.scanner.reportaddition(scanner.java:605) @ org.eclipse.jetty.util.scanner.reportdifferences(scanner.java:528) @ org.eclipse.jetty.util.scanner.scan(scanner.java:391) @ org.eclipse.jetty.util.scanner.dostart(scanner.java:313) which of course, true, though both abstracthandlers in end. might doing wrong or there way pull off?
using jetty 9.2.1
thanks
you have hardcoded deployments, don't use deploy module.
the exception getting deploy module attempting find , deploy webapps itself, , failing find org.eclipse.jetty.server.handler.contexthandler entry expecting.
the best way fix not have separate webapps depend on each other during deploy/init (that out of scope servlet spec). make /main_app/war/ webapp init on demand, not on startup.
now specific problem ...
important: not work / edit / run / configure
${jetty.home}directory directly.the
${jetty.base}directory exists reason, use it, you'll happier when do.http://www.eclipse.org/jetty/documentation/current/startup.html
for things load order sensitive, not use deploy module artifacts. (its safe use deploy module other webapps have don't have load order dependencies)
to accomplish this, we'll configure ${jetty.base} directory use custom xml file on startup, along /special/ directory these load order dependent webappcontexts, making sure these contexts not loaded, , managed deploy module.
$ cd my-jetty-base $ mkdir etc $ gvim etc/special-deploy.xml $ echo "etc/special-deploy.xml" >> start.ini $ ls -f etc/ special/ start.ini webapps $ ls -f special/ main.war security.war $ cat start.ini --module=http jetty.port=8080 --module=deploy etc/special-deploy.xml the special-deploy.xml looks ...
<?xml version="1.0"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure_9_0.dtd"> <!-- =============================================================== --> <!-- add load order dependant webapps --> <!-- =============================================================== --> <configure id="contexts" class="org.eclipse.jetty.server.handler.contexthandlercollection"> <call name="addhandler"> <arg> <new class="org.eclipse.jetty.webapp.webappcontext"> <set name="contextpath">/security</set> <set name="war"><systemproperty name="jetty.base"/>/special/security.war</set> <call name="addaliascheck"> <arg> <new class="org.eclipse.jetty.server.handler.contexthandler$approvepathprefixaliases"/> </arg> </call> </new> </arg> </call> <call name="addhandler"> <arg> <new class="org.eclipse.jetty.webapp.webappcontext"> <set name="contextpath">/</set> <set name="war"><systemproperty name="jetty.base"/>/special/main.war</set> <call name="addaliascheck"> <arg> <new class="org.eclipse.jetty.server.handler.contexthandler$approvepathprefixaliases"/> </arg> </call> </new> </arg> </call> </configure> when run you'll see following ...
$ java -jar /path/to/jetty-distribution-9.2.10.v20150310/start.jar 2015-04-29 12:18:55.929:info::main: logging initialized @275ms 2015-04-29 12:18:56.093:warn:oejsh.contexthandler:main: approvepathprefixaliases not safe production 2015-04-29 12:18:56.094:warn:oejsh.contexthandler:main: approvepathprefixaliases not safe production 2015-04-29 12:18:56.097:info:oejs.server:main: jetty-9.2.10.v20150310 2015-04-29 12:18:56.150:info:oejw.standarddescriptorprocessor:main: no jsp support /security, did not find org.eclipse.jetty.jsp.jettyjspservlet 2015-04-29 12:18:56.166:info:oejsh.contexthandler:main: started o.e.j.w.webappcontext@751d30f6{/security,file:/tmp/jetty-0.0.0.0-8080-security.war-_security-any-3863723758166154575.dir/webapp/,available}{/home/joakim/examples/load-order-example/special/security.war} 2015-04-29 12:18:56.181:info:oejw.standarddescriptorprocessor:main: no jsp support /, did not find org.eclipse.jetty.jsp.jettyjspservlet 2015-04-29 12:18:56.183:info:oejsh.contexthandler:main: started o.e.j.w.webappcontext@4f79a28b{/,file:/tmp/jetty-0.0.0.0-8080-main.war-_-any-2704851460101920295.dir/webapp/,available}{/home/joakim/examples/load-order-example/special/main.war} 2015-04-29 12:18:56.184:info:oejdp.scanningappprovider:main: deployment monitor [file:/home/joakim/examples/load-order-example/webapps/] @ interval 1 2015-04-29 12:18:56.195:info:oejs.serverconnector:main: started serverconnector@4ef6d773{http/1.1}{0.0.0.0:8080} 2015-04-29 12:18:56.196:info:oejs.server:main: started @542ms ^c2015-04-29 12:19:09.594:info:oejs.serverconnector:thread-0: stopped serverconnector@4ef6d773{http/1.1}{0.0.0.0:8080} 2015-04-29 12:19:09.599:info:oejsh.contexthandler:thread-0: stopped o.e.j.w.webappcontext@4f79a28b{/,file:/tmp/jetty-0.0.0.0-8080-main.war-_-any-2704851460101920295.dir/webapp/,unavailable}{/home/joakim/examples/load-order-example/special/main.war} 2015-04-29 12:19:09.602:info:oejsh.contexthandler:thread-0: stopped o.e.j.w.webappcontext@751d30f6{/security,file:/tmp/jetty-0.0.0.0-8080-security.war-_security-any-3863723758166154575.dir/webapp/,unavailable}{/home/joakim/examples/load-order-example/special/security.war}
Comments
Post a Comment