users@jersey.java.net

[Jersey] Re: Jersey test framework with EJBs, JPA & JTA

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Tue, 29 Mar 2011 11:40:33 +0200

On 3/28/11 7:46 PM, NBW wrote:
> As my previous message indicated I'm trying to get my jersey tests to
> run with embedded glassfish. For grins I tried firing it up with
> grizzly. My Jersey resource classes are also EJBs and when my test
> runs I see:
>
> Mar 28, 2011 1:09:24 PM
> com.sun.jersey.server.impl.ejb.EJBComponentProviderFactoryInitilizer
> initialize
> SEVERE: Error when configuring to use the EJB interceptor binding API.
> JAX-RS EJB support is disabled.
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> com.sun.jersey.server.impl.ejb.EJBComponentProviderFactoryInitilizer.initialize(EJBComponentProviderFactoryInitilizer.java:80)
> at
> com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:571)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:311)
> at
> com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
> at
> com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:213)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
> at javax.servlet.GenericServlet.init(GenericServlet.java:244)
> at
> com.sun.grizzly.http.servlet.ServletAdapter.loadServlet(ServletAdapter.java:456)
> at
> com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:395)
> at
> com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:349)
> at
> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
> at
> com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:183)
> at
> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
> at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
> at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
> at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
> at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
> at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
> at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
> at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
> at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
> at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
> at
> com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
> at
> com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: java.lang.IllegalStateException: no current invocation
> at
> com.sun.ejb.containers.InternalInterceptorBindingImpl.registerInterceptor(InternalInterceptorBindingImpl.java:72)
> ... 32 more
>
> So I thought perhaps Grizzly is not starting an EJB container. Also,
> as another wrinkle these EJBs use JPA with a JTA datasource that are
> inject as PersistenceContextswhich are looked up with JNDI against the
> container. This is the reason I originally wanted to run against the
> embedded glassfish test container, I figured I could configure it to
> point to my full install of GF so that it could leverage the
> domain.xml for these resources. This is what I do with my JUnit
> environment that needs to test these EJBs.
>
> I took a look at the jersey-ejb sample. That seems to use the default
> Grizzly test container so I am guessing that it /*does*/ start an EJB
> container? Is my attempt at using Grizzy failing because I have the
> additional JPA/JTA dependency?
>
> Any advice on the best way to approach this test environment? Thanks!
Hello Noah,

1) jersey-ejb does not use grizzly, it uses external container.
2) jersey-test-framework-embedded-glassfish is not quite ready for ejb
enabled webapps, there are some problems with container configuration
which we weren't able to address yet.

And my advice? Configure embedded-glassfish *maven plugin* to run
integration tests and use test framework but with an external container..

so something like this:

http://weblogs.java.net/blog/bhavanishankar/archive/2011/03/06/get-started-maven-plugin-embedded-glassfish-server-open-source-edition-31

I can provide more info / create sample if needed, so don't hesitate to
ask for it.

Regards,
Pavel


>
> -Noah
>