Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Servlet Initialization in Jetty 9.0.2

Gunnar,

The ServletHandler (in your case ApplicationServletHandler) is only created in ApplicationHandler.startContext(). So, if the ApplicationHandler has not been started, the ApplicationServletHandler does not exist, and so ApplicationContext line 310 should throw a null pointer when you try to add a ServletHolder.  Any reason why you can't create the ApplicationServletHandler in the constructor of ApplicationHandler - or maybe even better - override ServletContextHandler.newServletHandler() to return an instance of your ApplicationServletHandler class instead?

Jan


On 17 May 2013 11:52, Jan Bartel <janb@xxxxxxxxxxx> wrote:
Thanks Gunnar,

Looking at the code you provided the link to now. Do you have any output of a run with logging level DEBUG enabled?

thanks
Jan


On 17 May 2013 10:33, Gunnar Wagenknecht <gunnar@xxxxxxxxxxxxxxx> wrote:
On 2013-05-16 23:07:18 +0000, Jan Bartel said:

Can you post the code that sets up the servlets?  There were some changes to jetty-9 about how the holders are started, but I wouldn't have thought it could affect you, but if you post the code, then I'll have a better idea.

It's here:
http://git.eclipse.org/c/gyrex/gyrex-platform.git/tree/bundles/org.eclipse.gyrex.http.jetty/src/org/eclipse/gyrex/http/jetty/internal/app/ApplicationContext.java

Starting at line 304.

// create holder
final ServletHolder holder = new ServletHolder(servletClass);
if (null != initparams) {
        holder.setInitParameters(initparams);
}

// register servlet
applicationHandler.getServletHandler().addServletWithMapping(holder, pathSpec);


With Jetty 8 I had to do the following as well, because Jetty did not start the holders when the handler was already started.

if (applicationHandler.getServletHandler().isStarted() || applicationHandler.getServletHandler().isStarting()) {
try {
        holder.start();
} catch (final Exception e) {
        …
}





-Gunnar




--
Gunnar Wagenknecht
gunnar@xxxxxxxxxxxxxxx


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com – Developer advice, services and support
from the Jetty & CometD experts.



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com – Developer advice, services and support
from the Jetty & CometD experts.

Back to the top