1 2 Previous Next 16 Replies Latest reply on Feb 22, 2012 12:46 AM by brin jack

    TestCases for EJB3.1 with seam3, glassfish3.1.1

    brin jack Newbie

      I would like to create TestCases for EJB3.1 with seam3, glassfish3.1.1, richfaces4.1, jsf2.0 and hibernate. Added the following with different versions in pom.xml

      `

      <dependency>

                  <groupId>org.glassfish.extras</groupId>

                  <artifactId>glassfish-embedded-all</artifactId>

                  <version>3.1</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>junit</groupId>

                  <artifactId>junit</artifactId>

                  <version>4.8.1</version>

                  <scope>test</sc

      `

      throws error at ctx.lookup for the class or unable to create container or at entitymanager.

       

      Please provide an example for testcases in seam3 for ejb3.1 without the local interfaces.

       

      Thanks.

        • 1. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
          brin jack Newbie

          I would like to create TestCases for EJB3.1 with seam3, glassfish3.1.1, richfaces4.1, jsf2.0 and hibernate. Added the following with different versions in pom.xml

              

              

          <dependency>
                      <groupId>org.glassfish.extras</groupId>
                      <artifactId>glassfish-embedded-all</artifactId>
                      <version>3.1</version>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>junit</groupId>
                      <artifactId>junit</artifactId>
                      <version>4.8.1</version>
                      <scope>test</scope>
           </dependency>
          

          throws error at ctx.lookup for the class or unable to create container or at entitymanager.

           

          Please provide an example for testcases in seam3 for @Stateful ejb3.1 bean without the local interfaces.

           

          Thanks.

          • 2. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
            Jason Porter Master

            Are you using arquillian? If not, I strongly suggest going that route instead.

            • 3. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
              brin jack Newbie

              Not using arquillian. Any examples?

              • 4. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                Jason Porter Master

                They're all over the place, specifically for Seam 3 stuff though, look at the tests, most of them are using arquillian. Setup is pretty easy by using the arquillian-bom:

                 

                <dependency>
                  <groupId>org.jboss.arquillian</groupId>
                  <artifactId>arquillian-bom</artifactId>
                  <version>1.0.0.CR7</version>
                  <type>pom</type>
                </dependency>
                

                 

                in your pom.xml (in the dependencyManagement section) then include the server container you're using and the test library container (testng or junit) and you're good to go.

                • 5. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                  brin jack Newbie

                  Went through the examples, but did not get much help. The seam booking examples also do not work properly. The EJB container cannot be initialized. Arquillian tests throws "org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: " 

                  • 6. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                    brin jack Newbie

                    In case the testcases use the oracle database, how to add ojdbc14.jar to ShrinkWrap.

                    • 7. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                      Jason Porter Master

                      That will need to be in the app server, unless you're using oracle specific JDBC classes. You can't deploy the JDBC jar with the app and have the datasource come up, it must already be "install" and setup in the app server.

                      • 8. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                        brin jack Newbie

                        These testcases do not execute if

                        @Inject

                            private Conversation conversation;

                         

                        is present in the class. If all these are removed the testcases work.

                         

                        @PostConstruct
                            public void init() {
                                if (conversation.isTransient()) {
                                    conversation.begin();
                                }
                            }

                            @Remove
                            public void destroy() {
                                log.debug("destroy()");
                                if (!conversation.isTransient()) {
                                    conversation.end();
                                }
                            }

                         

                        Please suggest a solution for the same.

                        • 9. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                          Jason Porter Master

                          What exception are you receiving? Is it something to do with the scope not being active?

                          • 10. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                            brin jack Newbie

                            Error stack with    Conversation conversation injected

                             

                            Feb 22, 2012 9:51:55 AM org.jboss.arquillian.impl.XmlConfigurationBuilder loadArquillianConfiguration
                            INFO: building configuration from XML file: arquillian.xml
                            Feb 22, 2012 9:51:55 AM com.sun.ejb.containers.StatefulSessionContainer createEJBLocalBusinessObjectImpl
                            WARNING: ejb.create_ejblocalobject_exception
                            Feb 22, 2012 9:51:55 AM com.sun.ejb.containers.StatefulSessionContainer createEJBLocalBusinessObjectImpl
                            WARNING: create ejblocal object exception
                            javax.ejb.EJBException
                            at com.sun.ejb.containers.StatefulSessionContainer.afterInstanceCreation(StatefulSessionContainer.java:744)
                            at com.sun.ejb.containers.StatefulSessionContainer.createEJBLocalBusinessObjectImpl(StatefulSessionContainer.java:540)
                            at com.sun.ejb.containers.BaseContainer.createEJBLocalBusinessObjectImpl(BaseContainer.java:2425)
                            at com.sun.ejb.containers.EJBLocalHomeImpl.createEJBLocalBusinessObjectImpl(EJBLocalHomeImpl.java:113)
                            at com.sun.ejb.containers.EJBLocalHomeInvocationHandler.invoke(EJBLocalHomeInvocationHandler.java:153)
                            at $Proxy139.create(Unknown Source)
                            at com.sun.ejb.EJBUtils.resolveEjbRefObject(EJBUtils.java:362)
                            at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:186)
                            at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1040)
                            at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:688)
                            at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:657)
                            at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:148)
                            at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:428)
                            at javax.naming.InitialContext.lookup(InitialContext.java:392)
                            at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:513)
                            at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:384)
                            at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:168)
                            at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:126)
                            at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:47)
                            at org.jboss.weld.manager.SimpleInjectionTarget.inject(SimpleInjectionTarget.java:116)
                            at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectNonContextualInstance(CDIInjectionEnricher.java:114)
                            at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:93)
                            at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.enrich(CDIInjectionEnricher.java:52)
                            at org.jboss.arquillian.impl.handler.TestCaseEnricher.callback(TestCaseEnricher.java:42)
                            at org.jboss.arquillian.impl.handler.TestCaseEnricher.callback(TestCaseEnricher.java:32)
                            at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
                            at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
                            at org.jboss.arquillian.impl.EventTestRunnerAdaptor.before(EventTestRunnerAdaptor.java:130)
                            at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:206)
                            at org.jboss.arquillian.junit.Arquillian$5$1.evaluate(Arquillian.java:225)
                            at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                            at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:221)
                            at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
                            at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
                            at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
                            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:163)
                            at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)
                            at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                            at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)
                            at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                            at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
                            at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
                            at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
                            at org.jboss.arquillian.junit.JUnitTestRunner.execute(JUnitTestRunner.java:69)
                            at org.jboss.arquillian.protocol.servlet_3.ServletTestRunner.doGet(ServletTestRunner.java:84)
                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
                            at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
                            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
                            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
                            at org.jboss.seam.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:62)
                            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
                            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
                            at org.jboss.seam.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)
                            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
                            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
                            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
                            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
                            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
                            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
                            at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
                            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
                            at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
                            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
                            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
                            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:619)
                            Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type @ConversationScoped
                            at org.jboss.weld.conversation.ConversationImpl.checkConversationActive(ConversationImpl.java:79)
                            at org.jboss.weld.conversation.ConversationImpl.isTransient(ConversationImpl.java:234)
                            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 org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:304)
                            at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
                            at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
                            at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:298)
                            at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:113)
                            at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43)
                            at org.jboss.weld.conversation.ConversationImpl_$$_javassist_98.isTransient(ConversationImpl_$$_javassist_98.java)
                            at com.corelogic.terradactyl.ejb.customer.CustomerAction.init(CustomerAction.java:418)
                            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.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1006)
                            at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:61)
                            at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:390)
                            at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:373)
                            at com.sun.ejb.containers.StatefulSessionContainer.afterInstanceCreation(StatefulSessionContainer.java:742)
                            ... 83 more
                            Feb 22, 2012 9:51:55 AM org.hibernate.impl.SessionFactoryImpl close
                            INFO: closing
                            classLoader = WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
                            SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@e1f52a
                            Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 313.614 sec <<< FAILURE!

                            • 11. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                              Jason Porter Master

                              Yep:

                               

                              Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type @ConversationScoped

                               

                              Are you still using the embedded container or a full server? Whatever you're doing in your test isn't being done in an HttpServletRequest it seems.

                              • 12. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                                brin jack Newbie

                                I am using using the embedded container. But I did not get what you meant by :" your test isn't being done in an HttpServletRequest it seems".

                                 

                                Thanks.

                                • 13. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                                  Jason Porter Master

                                  The conversation context is only available during HTTP requests to the container. If this isn't an HTTP Request (which it isn't because you're using the embedded container adapter) there is no conversation context active.

                                  • 14. Re: TestCases for EJB3.1 with seam3, glassfish3.1.1
                                    brin jack Newbie

                                    Does this mean that Arquillian Testcases will not work for @ConversationScoped class using embedded glassfish container. or could you suggest a workaround for this conversation based class.

                                     

                                    1 2 Previous Next