Hi Henning, That looks like a genuine bug to me!
I opened https://bugs.eclipse.org/bugs/show_bug.cgi?id=389956 I'll take a look at this today. Jan On 19 September 2012 00:21, Henning Blohm <[email protected]> wrote: > We are embedding Jetty and today we noticed the following not quite trivial > bug in Jetty's start handling for Web apps. > > This bug was observed on Jetty 8.1.4 and as far as I can tell the relevant > code has not changed since then. It happens when you start a WebAppContext > from within a running Web app, i.e. while processing a request. In our > scenario, a Web app may be started on-demand and the trigger to do so may > occur while in a Web app. > > I checked with Jetty 6.1.22 (old integration) and it works ok there - I did > not debug it all the way through to see why it works there and not in 8.1.4. > > Here is what happens: > > When calling WebAppContext.start() you end up in WebAppContext.doStart() > which has this control flow: > > preConfigure(); > super.doStart(); > postConfigure(); > > In preConfigure, eventually EnvConfiguration.preConfigure(<context>) is > called and that is setting up the JNDI ENC. > > And here is where ContextFactory comes into the game: > > When looking for the class loader to identify a "java:comp" ENC from, > ContextFactory.getObjectInstance first consults > ContextHandler.getCurrentContext(). Only if that returns null, the current > thread's context class loader is considered. > > However, the switch of Jetty Contexts in ContextHandler is done in > ContextHandler.doStart(), i.e. only after the call to preConfigure() in > WebAppContext.doStart(). > > Now, if you are not in a Web App and you want to start a WebAppContext and > the current thread's context classloader is set, then > ContextHandler.getCurrentContext()==null and you get an ENC for the new Web > App as expected. > > But if you are currently processing a Web app request, then > ContextHandler.doScope will have set that Web app's context and > ContextHandler.getCurrentContext()!=null and ContextFactory will try to > create an ENC for a loader that already has one and you get: > > Caused by: javax.naming.NamingException: This context is immutable; > remaining name 'env' > at > org.eclipse.jetty.jndi.NamingContext.createSubcontext(NamingContext.java:302) > at > org.eclipse.jetty.jndi.NamingContext.createSubcontext(NamingContext.java:383) > at > org.eclipse.jetty.plus.webapp.EnvConfiguration.createEnvContext(EnvConfiguration.java:253) > at > org.eclipse.jetty.plus.webapp.EnvConfiguration.preConfigure(EnvConfiguration.java:67) > at > org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:430) > at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466) > at > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59) > > Please let me know, if there is some way of getting around this. Hope there > was sufficient details and sorry for the complex case. > > Thanks, > Henning > _______________________________________________ > jetty-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/jetty-users -- Jan Bartel <[email protected]> www.webtide.com – Developer advice, services and support from the Jetty & CometD experts. _______________________________________________ jetty-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/jetty-users
