Here is the scenario,
·
webapp contains a web.xml
·
one of the jars contain ServletContainerInitializer
META-INF/services/javax.servlet.ServletContainterInitializer
We are starting jetty programmatically, by using XMLConfiguration which is configured with a server object.
Here is the code snippet,
XmlConfiguration configuration
= new
XmlConfiguration(in);
if (type.isInstance(server))
{
configuration.configure(server);
return;
}
boolean success =
false;
for (Handler
handler : ((Server) server).getHandlers())
{
if (type.isInstance(handler))
{
configuration.configure(handler);
success =
true;
}
}
Here is the context.xml used
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Configure class="org.eclipse.jetty.server.Server" id="Server">
<Set name="ThreadPool">
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">2</Set>
<Set name="maxThreads">10</Set>
<Set name="detailedDump">false</Set>
</New>
</Set>
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="port">8080</Set>
<Set name="maxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
</New>
</Arg>
</Call>
<Set name="handler">
<New class="org.eclipse.jetty.webapp.WebAppContext">
<Arg type="String">src/main/webapp</Arg>
<Arg type="String">/</Arg>
<Set name="extraClasspath">S:/git/projects/p1/target/classes;
S:/maven.repo/org/apache/ahc/1.1.2/ahc-1.1.2.jar;
S:/maven.repo/com/sun/xml/bind/jaxb-xjc/2.2.3.20110115/jaxb-xjc-2.2.3.20110115.jar;
S:/maven.repo/com/springsource/org/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar;
S:/maven.repo/com/springsource/org/jdom/1.0.0/jdom-1.0.0.jar;
S:/maven.repo/org/apache/mina/1.1.9/mina-1.1.9.jar;
S:/maven.repo/com/springsource/com/mysql/jdbc/5.1.6/jdbc-5.1.6.jar;
</Set>
</New>
</Set>
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
<Set name="dumpAfterStart">false</Set>
<Set name="dumpBeforeStop">false</Set>
</Configure>
When invoked from CLI, jetty DeploymentManager scans the classpath and calls the ServletContainerInitializer provided inside the jar files. What is the equivalent for that to be provided in the
XML config file?
When the code is deployed as a war into a jetty installation everything works as expected. So, that confirms everything is correct.
http://stackoverflow.com/questions/18775758/jetty-servletcontainerinitialization-sci-doesnt-call-an-initializer-provided
Thanks
Nambi