Hi Poul,
I got around to try adapt your example for my app. Unfortunately, it does not seem to work inside my app. The problem seems that it assumes JNDI is present as seen in the stacktrace below... So I guess the JCDIComponentProviderFactory class needs to be refactored as you mentioned to remove all JEE references (i.e. so it works without the EE annotations API and without JNDI). I already created a bug report for the problem last week which I guess we can just add to ?
P.S: Not sure why you don't get this error. Maybe I have diff stuff in my classpath because my app is hybrid JEE and JSEE depending on how or run it ?
ERROR:
java.lang.NullPointerException
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:297)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:271)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.jersey.server.impl.managedbeans.ManagedBeanComponentProviderFactoryInitilizer.initialize(ManagedBeanComponentProviderFactoryInitilizer.java:56)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:492)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:246)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:520)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:199)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:308)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:471)
at javax.servlet.GenericServlet.init(GenericServlet.java:242)
at com.sun.grizzly.http.servlet.ServletAdapter.loadServlet(ServletAdapter.java:428)
at com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:367)
at com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:324)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
at com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:180)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:637)
--- Den tirs 27/4/10 skrev Paul Sandoz <Paul.Sandoz_at_Sun.COM>:
> Fra: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> Emne: Weld on SE with Jersey and Grizzly
> Til: "Jersey-Users Mailing List" <users_at_jersey.dev.java.net>
> Cc: "Morten" <mortench2004_at_yahoo.dk>
> Dato: tirsdag 27. april 2010 17.21
> Hi Morten,
>
> Attached is a basic example of using Weld on SE with Jersey
> and Grizzly.
>
> I think you were perhaps running into issues with
> dependences. Note that JCDIComponentProviderFactory is not
> currently not part of the public API. It has a dependency on
> the java EE annotations API. If we want to make
> JCDIComponentProviderFactory public we can split the class
> up to be CDI and CDI+EE dependent.
>
> What the example does not support @RequestScoped. To do
> that requires some additional declaration in Grizzly to
> declare a weld-based context so it can manage the
> request-scoped classes when a request starts and finishes.
>
> I am assuming for the Grizzly Web-based support this should
> be relatively straight forward e.g. a servlet context
> listener declaration. However, for the low-level Grizzly
> support this will require some specific Grizzly/Weld
> integration.
>
> Paul.
>
>
>