spring - Jetty startup delay due to scanning -
context , setup information:
- jetty 9 eclipse jetty plugin
- spring 4.1.1.release spring security 3.2.3
- spring java configuration (no web.xml)
problem description starting jetty 9 slow in project spring's javaconfig used boot spring context instead of using web.xml
. jetty seems doing nothing during considerate amount of time. occurs after line:
info:oejs.server:main: jetty-9.2.3.v20140905
jetty start eventually, takes long start compared regular tomcat 7 distribution.
additional resources
public class dispatcherservletinitializer extends abstractannotationconfigdispatcherservletinitializer { //implementation }
this due fact jetty 9 scans jars in web-inf folder annotations in order start web context. if you've attempted find solution problem, discovered fact. tried several such answers, never found correct solution among them.
in order eliminate such scanning as possible, can define pattern tells jetty sources scan , not scan. done either setting configuration in maven, or setting attribute in jetty-context.xml
. (if using maven plugin, need set jetty's jetty-context.xml
in pom.xml
)
some other solutions have not worked me (either no increase in startup time or no correct startup @ all)
jetty 8.1.2 startup delay jetty8 maven plugin takes long start
etc.
the correct solution done using such jetty-context.xml
, pattern. in spring application, need scan spring jars, , alone give massive boost if have many dependencies. better if scan spring-web
jars instead. if have spring security, might needed include jars.
as such, pattern gave me maximum speedup shown here:
<?xml version="1.0"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure_9_0.dtd"> <configure class="org.eclipse.jetty.webapp.webappcontext"> <call name="setattribute"> <arg>org.eclipse.jetty.server.webapp.webinfincludejarpattern</arg> <arg>.*/spring-security[^/]*\.jar$|.*/spring-web[^/]*\.jar$|.*/classes/.*</arg> </call> </configure>
we exclude not in our classes
folder in web-inf
, jars not include regex pattern given.
hope helps someone!
Comments
Post a Comment