2 Replies Latest reply on Oct 28, 2012 9:46 PM by Richard Lucas

    Exception attempting to inject Remote ejb-ref when running multiple tests

    Richard Lucas Apprentice

      I have a number of test classes that are run using Arquillian (1.0.2.Final) using the 'arquillian-glassfish-embedded-3.1' container (1.0.0.CR3).

       

      If I run any of the test classes in isolation they run as expected, if I attempt to run multiple test classes (TestSuite) I run into problems injecting EJB's into the classes.

       

       

      shouldFailToUpdateTransmission(com.dcp.transmission.TransmissionManagerBeanTest)  Time elapsed: 0.046 sec  <<< ERROR!
      java.lang.RuntimeException: Could not inject members
                at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:135)
                at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.enrich(CDIInjectionEnricher.java:78)
                at org.jboss.arquillian.test.impl.TestInstanceEnricher.enrich(TestInstanceEnricher.java:52)
                at sun.reflect.GeneratedMethodAccessor59.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
                at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
                at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
                at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
                at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
                at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.before(EventTestRunnerAdaptor.java:95)
                at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:222)
                at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
                at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
                at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)
                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
                at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)
                at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
                at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
                at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
                at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
                at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
                at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)
                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)
                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)
                at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
                at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
                at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
                at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
                at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
                at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
                at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
                at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
                at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
                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:680)
      Caused by: java.lang.IllegalStateException: Exception attempting to inject Remote ejb-ref name=PackageManagerBean,Remote 3.x interface =com.dcp.pkg.PackageManager resolved to intra-app EJB PackageManagerBean in module test,ejb-link=PackageManagerBean,lookup=,mappedName=,jndi-name=PackageManagerBean,refType=Session into class com.dcp.transmission.TransmissionManagerBeanTest: Lookup failed for 'java:comp/env/PackageManagerBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
                at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:137)
                at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
                at org.jboss.weld.manager.SimpleInjectionTarget.inject(SimpleInjectionTarget.java:102)
                at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectNonContextualInstance(CDIInjectionEnricher.java:145)
                at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:125)
                ... 78 more
      Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=PackageManagerBean,Remote 3.x interface =com.dcp.pkg.PackageManager resolved to intra-app EJB PackageManagerBean in module test,ejb-link=PackageManagerBean,lookup=,mappedName=,jndi-name=PackageManagerBean,refType=Session into class com.dcp.transmission.TransmissionManagerBeanTest: Lookup failed for 'java:comp/env/PackageManagerBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
                at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:703)
                at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:470)
                at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:171)
                at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:130)
                ... 82 more
      Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/PackageManagerBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=PackageManagerBean,Remote 3.x interface =com.dcp.pkg.PackageManager resolved to intra-app EJB PackageManagerBean in module test,ejb-link=PackageManagerBean,lookup=,mappedName=,jndi-name=PackageManagerBean,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'PackageManagerBean#com.dcp.pkg.PackageManager' [Root exception is javax.naming.NamingException: Lookup failed for 'PackageManagerBean#com.dcp.pkg.PackageManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.dcp.pkg.PackageManager [Root exception is java.lang.IllegalArgumentException: argument type mismatch]]]]
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
                at javax.naming.InitialContext.lookup(InitialContext.java:392)
                at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:599)
                ... 85 more
      Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=PackageManagerBean,Remote 3.x interface =com.dcp.pkg.PackageManager resolved to intra-app EJB PackageManagerBean in module test,ejb-link=PackageManagerBean,lookup=,mappedName=,jndi-name=PackageManagerBean,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'PackageManagerBean#com.dcp.pkg.PackageManager' [Root exception is javax.naming.NamingException: Lookup failed for 'PackageManagerBean#com.dcp.pkg.PackageManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.dcp.pkg.PackageManager [Root exception is java.lang.IllegalArgumentException: argument type mismatch]]]
                at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:191)
                at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1109)
                at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776)
                at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744)
                at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:169)
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498)
                ... 88 more
      Caused by: javax.naming.NamingException: Lookup failed for 'PackageManagerBean#com.dcp.pkg.PackageManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.dcp.pkg.PackageManager [Root exception is java.lang.IllegalArgumentException: argument type mismatch]]
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
                at javax.naming.InitialContext.lookup(InitialContext.java:392)
                at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:186)
                ... 93 more
      Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.dcp.pkg.PackageManager [Root exception is java.lang.IllegalArgumentException: argument type mismatch]
                at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:434)
                at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75)
                at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
                at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
                at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
                ... 96 more
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                at com.sun.ejb.EJBUtils.createRemoteBusinessObject(EJBUtils.java:657)
                at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:427)
                ... 100 more
      
      
      

       

      The Package Manager Bean is defined as follows:

       

      @Stateless(mappedName = "PackageManagerBean")
      @Remote({ PackageManager.class })
      @Local({ PackageManagerLocal.class })
      public class PackageManagerBean implements PackageManager {
      
      }
      

       

      The Package Manager is injected into several of the test classes as per the example below:

       

      @RunWith(Arquillian.class)
      public class TransmissionManagerBeanTest {
      
        @Deployment
                public static Archive<?> createDeployment() {
                          WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
                                              .addPackages(true, TransmissionManager.class.getPackage(), Search.class.getPackage(), PackageManager.class.getPackage(), SiteManagerBean.class.getPackage())
                                              .addAsResource("test-persistence.xml", "META-INF/persistence.xml").addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
                          return war;
                }
      
        @EJB
                TransmissionManager transmissionManager;
      
        @EJB
                PackageManager packageManager;
      
        @EJB
                SiteManager siteManager;
      
        @PersistenceContext
                EntityManager entityManager;
      
        @Inject
                UserTransaction userTransaction;
      
      }
      
      

       

      I do not appear to be having problems with any of the other EJB's.

       

      Does any one have any idea what the problem is and how I can get this working?

       

      UPDATE:

       

      I have tried to run the same tests on both the managed and remote glassfish containers and am running into a different set of issues:

       

      1. It is complaining that one of the enums in Entity bean does not implement Serializable

       

      Internal Exception: Exception [EclipseLink-7155] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
      Exception Description: The type [class com.dcp.Status] for the attribute [status] on the entity class [class com.dcp.command.Command] is not a valid type for a serialized mapping. 
      The attribute type must implement the Serializable interface.. Please see server.log for more details. [status: CLIENT_ERROR reason: Bad Request]
      
      

       

      2. It complains that the DeploymentContext does not contain any EJB

       

      SEVERE: exit_code: FAILURE, message: Error occurred during deployment: Exception while preparing the app : Unable to load the EJB module. DeploymentContext does not contain any EJB. 
      Check the archive to ensure correct packaging for /apps/glassfish3/glassfish/domains/domain1/applications/test.