Hi Poul,
No, actually in my Java SE 6 environment where I am trying this out I do not even have JNDI up and running (even though some of its classes may be available on the classpath because of the hybrid nature of my project). I can see 3 options.
1) Is there a property in Jersey which informs it NOT to use any JEE features - i.e. Java SE only ?
2) Setting up my own dummy JNDI for jersey under Java SE if I happen to have an JNDI impl. in my classpath (have to find a way to search for JNDI impl. then).
3) Not use Jersey's ServletAdaptor for Grizzly but use the more simple GrizzlyServerFactory.create (what I am during now)
--- Den man 3/5/10 skrev Paul Sandoz <Paul.Sandoz_at_Sun.COM>:
> Fra: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> Emne: [Jersey] Re: SV: Weld on SE with Jersey and Grizzly
> Til: "Morten" <mortench2004_at_yahoo.dk>
> Cc: "Jersey-Users Mailing List" <users_at_jersey.dev.java.net>
> Dato: mandag 3. maj 2010 09.24
> Hi Morten,
>
> It looks like the JNDI set in your environment is bust. It
> is not a bug in Jersey.
>
> The JNDI API is part of SE 5 and if one looks up an object
> for a name, but the object does not exist then JNDI should
> throw a NamingException. This is why it works fine for me on
> SE (see the code at the end of the email).
>
> The reason why JCDIComponentProviderFactory should be
> refactored is to remove a dependency on the
> javax.annotations API which would not be required in SE
> environments. It does not use JNDI,
> JCDIComponentProviderFactoryInitializer that creates it uses
> JNDI and if JNDI is behaving correctly the latter should
> fail gracefully if BeanManager cannot be looked up (as
> should be the case for
> ManagedBeanComponentProviderFactoryInitilizer).
>
> Paul.
>
> public final class
> ManagedBeanComponentProviderFactoryInitilizer {
>
> private static final Logger LOGGER =
> Logger.getLogger(
>
> ManagedBeanComponentProviderFactoryInitilizer.class.getName());
>
> public static void initialize(ResourceConfig
> rc) {
> try {
> InitialContext ic
> = InitialContextHelper.getInitialContext();
> if (ic == null)
> {
>
> return;
> }
> Object
> injectionMgr = ic.
>
>
> lookup("com.sun.enterprise.container.common.spi.util.InjectionManager");
> // Some
> implementations of InitialContext return null instead of
> // throwing
> NamingException if there is no Object associated with
> // the name
> if (injectionMgr
> == null) {
>
> LOGGER.config("The managed beans injection manager API is
> not available. JAX-RS managed beans support is disabled.");
>
> return;
> }
>
> Method
> createManagedObjectMethod = injectionMgr.getClass().
>
> getMethod("createManagedObject",
> java.lang.Class.class);
>
> Method
> destroyManagedObjectMethod = injectionMgr.getClass().
>
> getMethod("destroyManagedObject",
> java.lang.Object.class);
>
>
> rc.getSingletons().add(new
> ManagedBeanComponentProviderFactory(
>
> injectionMgr, createManagedObjectMethod,
> destroyManagedObjectMethod));
> } catch (NamingException ex) {
>
> LOGGER.log(Level.CONFIG, "The managed beans injection
> manager API is not available. JAX-RS managed beans support
> is disabled.", ex);
> } catch (NoSuchMethodException
> ex) {
>
> LOGGER.log(Level.SEVERE, "The managed beans injection
> manager API does not conform to what is expected. JAX-RS
> managed beans support is disabled.", ex);
> } catch (SecurityException ex)
> {
>
> LOGGER.log(Level.SEVERE, "Security issue when configuring to
> use the managed beans injection manager API. JAX-RS managed
> beans support is disabled.", ex);
> } catch (LinkageError ex) {
>
> LOGGER.log(Level.SEVERE, "Linkage error when configuring to
> use the managed beans injection manager API. JAX-RS managed
> beans support is disabled.", ex);
> }
> }
> }
>
> On May 2, 2010, at 1:32 AM, Morten wrote:
>
> > 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>:
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>