Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004215 [Resin] major always 09-16-10 06:48 11-15-10 09:12
Reporter olaf2010 View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 4.0.10
Summary 0004215: Conflict between jersey and resin (and again, with example war)
Description Hello reza,

you are faster with closing bugs then me is able to attach some code sample. :-)

Its related to:

- [^]

The "jerseytest.war" you can get from here (uploading to mantis failed)

- [^]

I have checked it against resin4.0.10 and resin-4.0.s100819 as well, downloaded just a few secs ago.

I put the "jerseytest.war" into webapps directory, started resin and called:

http://localhost:8080/jerseytest/ [^]

"Hello World" should be printed, but i get the NPE instead.

So far there are only 3 dependencies in the war and nothing else. Needless to say, with resin2.1.17 it works.

    at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(
    at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(
    at com.sun.jersey.spi.container.servlet.WebComponent.configure(
    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(
    at com.sun.jersey.spi.container.servlet.WebComponent.load(
    at com.sun.jersey.spi.container.servlet.WebComponent.init(
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(
    at javax.servlet.GenericServlet.init(
    at com.caucho.server.dispatch.ServletConfigImpl.createServletImpl(
    at com.caucho.server.dispatch.ServletConfigImpl.createServlet(
    at com.caucho.server.dispatch.ServletFilterChain.doFilter(
    at com.caucho.server.webapp.WebAppFilterChain.doFilter(
    at com.caucho.server.webapp.AccessLogFilterChain.doFilter(
    at com.caucho.server.dispatch.ServletInvocation.service(
    at com.caucho.server.http.HttpRequest.handleRequest(
    at com.caucho.env.thread.ResinThread.runTasks(

I hope you can reproduce it as well.
Additional Information
Attached Files

- Relationships

- Notes
11-04-10 11:30

Jersey does not use its init process with a "thread local" variable anymore. Since resin (and other container) do the init stuff in a different thread.

So, instead they store their stuff now in a JNDI context named:


This causes trouble:

[10-11-04 19:22:01.920] {resin-16} javax.naming.NameNotFoundException: /com.sun.jersey.config/CDIExtension
                                       at com.caucho.naming.ContextImpl.rebind(
                                       at javax.naming.InitialContext.rebind(
                                       at com.sun.jersey.server.impl.cdi.CDIExtension.initialize(
                                       at com.sun.jersey.server.impl.cdi.CDIExtension.beforeBeanDiscovery(

I have changed the name to "com.sun.jersey.config/CDIExtension", same exception.

As soon as i change the name to "CDIExtension" only, it works.

Can it be, that com.caucho.naming.ContextImpl.rebind( has a problem with slashes in the name?
11-04-10 11:43

Ok, it seems, in JNDI the "/" character is special and needs to be quoted, if used. I guess then, this is a jersey bug at all.

Nonetheless the exception from resin is confusing, since its not a "NameNotFoundException", its rather the name itself, which is broken.
11-04-10 11:45

And finally, jersey project seems to be locked now. I can not even file a bug/patch there. Hm
11-09-10 16:34

The slash in JNDI isn't illegal, exactly. It's like a directory, and the application is supposed to create the parent context/directory.

It would be easy for us to change that behavior to automatically create the directory, but we'd need to double check the JNDI (or see if there's some reason that jersey is trying to create that context and we're not allowing it.)
11-10-10 04:07

Jersey has finally moved and i can submit bugs there

- [^]

They have an CDIExtension, which has a method:

  void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event) {...}

Thats also where they store the CDIExtension instance in the JNDI context. This is their second try to workaround for something else, that doesnt work:

They tried to lookup CDIExtension in:

Object beanManager = ic.lookup("java:comp/BeanManager");

The beanManager itself is not null, but there is never an instance of CDIExtension.
11-12-10 10:57

That definitely looks like a Jersey bug.

From the JNDI JavaDoc: rebind() "Binds a name to an object, overwriting any existing binding. All intermediate contexts and the target context (that named by all but terminal atomic component of the name) must already exist."

The error is because Jersey never creates the "com.sun.jersey.config" component (and I can't really change Resin to use a non-conforming JNDI context.)

There is a workaround for Jersey, though. Set the following system-property in the resin.xml:

<resin ...>
11-12-10 16:15

Thank you for the advice. But this creates the "original" NPE for which they have had to create the JNDI workaround (or former thread-local). They cant find for any obscure reason their "CDIExtension" instance in the BeanManager. So they go the way over JNDI and save the instance in that "beforeBeanDiscovery" method. Where they fail with resin, due to this rebind things.

Well, ok, i will try to change the source code, so that /com.sun.jersey.config/CDIExtension will be created as necessary. Maybe they like what they see. So far no reaction on my report there.
11-12-10 18:23

Please try 4.0.13, because 4.0.10 is old and the 4.0.13 release is more recent than the snapshot.
11-13-10 08:41

Good news.

With resin 4.0.13 it works again, when setting the system property:


With resin 4.0.10 it does not work. I just checked once more.

Whatever changes you guys did: Thank you.
11-15-10 09:12

thanks for the update. I'm closing this as fixed.

- Issue History
Date Modified Username Field Change
09-16-10 06:48 olaf2010 New Issue
11-04-10 11:30 olaf2010 Note Added: 0004819
11-04-10 11:43 olaf2010 Note Added: 0004820
11-04-10 11:45 olaf2010 Note Added: 0004821
11-09-10 16:34 ferg Note Added: 0004824
11-10-10 04:07 olaf2010 Note Added: 0004826
11-12-10 10:57 ferg Note Added: 0004832
11-12-10 16:15 olaf2010 Note Added: 0004834
11-12-10 18:23 ferg Note Added: 0004835
11-13-10 08:41 olaf2010 Note Added: 0004836
11-15-10 09:12 ferg Note Added: 0004840
11-15-10 09:12 ferg Assigned To  => ferg
11-15-10 09:12 ferg Status new => closed
11-15-10 09:12 ferg Resolution open => fixed
11-15-10 09:12 ferg Fixed in Version  => 4.0.13

Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
47 total queries executed.
35 unique queries executed.
Powered by Mantis Bugtracker