9 Replies Latest reply: May 28, 2012 12:19 PM by Bernard Labno RSS

Arquillian Testcases for Seam 3 @ConversationScoped class

brin jack Newbie

Arquillian Testcases for Seam 3 @ConversationScoped class fails if it has the following.

 

@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.

error :

 

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!

 

Thanks.

  • 1. Re: Arquillian Testcases for Seam 3 @ConversationScoped class
    brin jack Newbie

    With embedded glassfish 3.1, Seam3.

  • 2. Re: Arquillian Testcases for Seam 3 @ConversationScoped class
    Bartosz Majsak Master

    I believe you need to activate conversation context first. One way of doing it I described while back in this blog post.But maybe there are now some other, bettter ways to do it. I would recommend looking at Seam3 Examples where they have tests of each module.

  • 3. Re: Arquillian Testcases for Seam 3 @ConversationScoped class
    Aslak Knutsen Master

    ConversationScope is only available within a JSF request pr EE spec.

  • 4. Re: Arquillian Testcases for Seam 3 @ConversationScoped class
    brin jack Newbie

    Thanks. It works now.

     

    The issue I have come across is that if the testcases execute once, then even if no changes are made it does not execute for 5 to 6 times. Then it executes again without any changes.

  • 5. Re: Arquillian Testcases for Seam 3 @ConversationScoped class
    brin jack Newbie

    Testcases fail 50% of the time and I get the following:

     

    java.lang.IllegalStateException: Singleton is not set
    at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$IsolatedStaticSingleton.get(IsolatedStaticSingletonProvider.java:52)
    at org.jboss.weld.Container.instance(Container.java:58)
    at com.corelogic.terradactyl.scope.handler.ConversationScopeHandler.initializeContext(ConversationScopeHandler.java:12)
    at com.corelogic.terradactyl.scope.handler.ScopeHandlingRule.starting(ScopeHandlingRule.java:22)
    at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:46)
    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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
    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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)

     

    what could be the reason

     

     

  • 6. Re: Arquillian Testcases for Seam 3 @ConversationScoped class
    Aslak Knutsen Master

    What's your pom.xml and arquillian.xml look like?

  • 7. Re: Arquillian Testcases for Seam 3 @ConversationScoped class
    brin jack Newbie

    pom.xml dependencies--------

     

    <!-- SEAM dependencies -->
            <dependency>
                <groupId>org.jboss.seam.solder</groupId>
                <artifactId>seam-solder-tooling</artifactId>
                <scope>provided</scope>
                <optional>true</optional>
            </dependency>

            <dependency>
                <groupId>org.jboss.seam.solder</groupId>
                <artifactId>seam-solder</artifactId>
            </dependency>

            <dependency>
                <groupId>org.jboss.seam.faces</groupId>
                <artifactId>seam-faces-api</artifactId>
                <scope>compile</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.seam.faces</groupId>
                <artifactId>seam-faces-impl</artifactId>
                <scope>runtime</scope>
            </dependency>

            <!--dependency>
                <groupId>org.jboss.seam.reports</groupId>
                <artifactId>seam-reports-api</artifactId>
                <version>3.1.0.Beta5</version>
            </dependency-->

            <dependency>
                <groupId>org.jboss.seam.servlet</groupId>
                <artifactId>seam-servlet</artifactId>
            </dependency>

            <dependency>
                <groupId>org.jboss.seam.catch</groupId>
                <artifactId>seam-catch</artifactId>
            </dependency>

            <dependency>
                <groupId>org.jboss.seam.security</groupId>
                <artifactId>seam-security</artifactId>
                <exclusions>
                    <exclusion>
                        <artifactId>seam-persistence</artifactId>
                        <groupId>org.jboss.seam.persistence</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.jboss.seam.persistence</groupId>
                <artifactId>seam-persistence</artifactId>
                <type>jar</type>
            </dependency>

            <!-- end SEAM dependencies -->

            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
            </dependency>

            <!-- Jakarta Commons -->
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.6</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <version>1.1.1</version>
                <exclusions>
                    <exclusion>
                        <groupId>avalon-framework</groupId>
                        <artifactId>avalon-framework</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>logkit</groupId>
                        <artifactId>logkit</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>javax.servlet</groupId>
                        <artifactId>servlet-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>commons-configuration</groupId>
                <artifactId>commons-configuration</artifactId>
                <version>1.6</version>
            </dependency>
            <!-- end Jakarta Commons -->  

            <!-- log4j -->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <scope>compile</scope>
            </dependency>
            <!-- end log4j -->

            <dependency>
                <groupId>edu.oswego</groupId>
                <artifactId>concurrent</artifactId>
                <version>1.3.4</version>
            </dependency>
           
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.6.1</version>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-jdk14</artifactId>
                <version>1.6.1</version>
            </dependency>
           
            <dependency>
                <groupId>javax.enterprise</groupId>
                <artifactId>cdi-api</artifactId>
                <version>1.0-SP4</version>
            </dependency>

            <!-- JPA 2 annotation processor -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-jpamodelgen</artifactId>
                <version>1.0.0.Final</version>
                <scope>provided</scope>
                <exclusions>
                    <exclusion>
                        <artifactId>slf4j-api</artifactId>
                        <groupId>org.slf4j</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>asm</groupId>       
                <artifactId>asm</artifactId>           
                <version>3.3.1</version>
            </dependency>
            <dependency>
                <groupId>asm</groupId>         
                <artifactId>asm-all</artifactId>           
                <version>3.3.1</version>
            </dependency>
            <dependency>
                <groupId>asm</groupId>         
                <artifactId>asm-attrs</artifactId>           
                <version>2.2.3</version>
            </dependency>
            <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>2.2.2</version>                       
            </dependency>
           
            <!-- hibernate -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>3.3.1.ga</version>
                <exclusions>
                    <exclusion>
                        <artifactId>jta</artifactId>
                        <groupId>javax.transaction</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>commons-logging</artifactId>
                        <groupId>commons-logging</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>slf4j-api</artifactId>
                        <groupId>org.slf4j</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>hibernate-core</artifactId>
                        <groupId>org.hibernate</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>asm</artifactId>
                        <groupId>asm</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>asm-attrs</artifactId>
                        <groupId>asm</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>cglib</artifactId>
                        <groupId>cglib</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-annotations</artifactId>
                <version>3.3.1.GA</version>
                <exclusions>
                    <exclusion>
                        <artifactId>hibernate</artifactId>
                        <groupId>org.hibernate</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>slf4j-api</artifactId>
                        <groupId>org.slf4j</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>hibernate-core</artifactId>
                        <groupId>org.hibernate</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>4.1.0.Final</version>
                <exclusions>
                    <exclusion>
                        <artifactId>hibernate</artifactId>
                        <groupId>org.hibernate</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>slf4j-api</artifactId>
                        <groupId>org.slf4j</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>       
            </dependency>
            <!-- end hibernate -->
           
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>r08</version>
            </dependency>       

            <!-- Test Dependencies -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.8.2</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-junit</artifactId>
                <version>${arquil.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.glassfish.extras</groupId>
                <artifactId>glassfish-embedded-all</artifactId>
                <version>3.0.1</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-glassfish-embedded-3</artifactId>
                <version>${arquil.version}</version>
                <scope>test</scope>           
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian.testenricher</groupId>
                <artifactId>arquillian-testenricher-cdi</artifactId>
                <version>${arquil.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian.testenricher</groupId>
                <artifactId>arquillian-testenricher-ejb</artifactId>
                <version>${arquil.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian.testenricher</groupId>
                <artifactId>arquillian-testenricher-resource</artifactId>
                <version>${arquil.version}</version>
            </dependency>       

            <dependency>
                <groupId>org.jboss.shrinkwrap</groupId>
                <artifactId>shrinkwrap-api</artifactId>
                <version>1.0.0-alpha-11</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap</groupId>
                <artifactId>shrinkwrap-extension-glassfish</artifactId>
                <version>1.0.0-alpha-11</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap</groupId>
                <artifactId>shrinkwrap-impl-base</artifactId>
                <version>1.0.0-alpha-11</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap</groupId>
                <artifactId>shrinkwrap-spi</artifactId>
                <version>1.0.0-alpha-11</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
                <version>1.0.0-beta-5</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <artifactId>google-collections</artifactId>
                        <groupId>com.google.collections</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                <artifactId>shrinkwrap-resolver-api-maven</artifactId>
                <version>1.0.0-beta-5</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap.descriptors</groupId>
                <artifactId>shrinkwrap-descriptors-impl</artifactId>
                <scope>test</scope>
            </dependency>
           
            <dependency>
                <groupId>org.drools</groupId>
                <artifactId>drools-api</artifactId>
                <version>5.1.1</version>
                <scope>test</scope>
            </dependency>      

            <dependency>
                <groupId>org.jboss.logmanager</groupId>
                <artifactId>jboss-logmanager</artifactId>
                <version>1.2.2.GA</version>
                <scope>test</scope>
            </dependency>
            <!-- End Test Dependencies --> 
           
            <!-- Java EE provided jars -->

            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-web-api</artifactId>
                <version>6.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- end Java EE provided jars -->


            <!-- Excel and PDF report generation jars -->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.5-FINAL</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.itextpdf</groupId>
                <artifactId>itextpdf</artifactId>
                <version>5.1.3</version>
                <scope>compile</scope>
                <exclusions>
                    <exclusion>
                        <artifactId>bcmail-jdk14</artifactId>
                        <groupId>org.bouncycastle</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>bcprov-jdk14</artifactId>
                        <groupId>org.bouncycastle</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>bctsp-jdk14</artifactId>
                        <groupId>org.bouncycastle</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

            <!-- geotools -->
            <dependency>
                <groupId>org.geotools</groupId>
                <artifactId>gt2-main</artifactId>
                <version>${gt.version}</version>
            </dependency>
            <dependency>
                <groupId>org.geotools</groupId>
                <artifactId>gt2-oracle-spatial</artifactId>
                <version>${gt.version}</version>
            </dependency>
            <dependency>
                <groupId>org.geotools</groupId>
                <artifactId>gt2-cql</artifactId>
                <version>${gt.version}</version>
            </dependency>
            <dependency>
                <groupId>org.geotools</groupId>
                <artifactId>gt2-shapefile</artifactId>
                <version>${gt.version}</version>
            </dependency>
            <dependency>
                <groupId>org.geotools</groupId>
                <artifactId>gt2-epsg-wkt</artifactId>
                <version>${gt.version}</version>
            </dependency>
            <dependency>
                <groupId>org.geotools</groupId>
                <artifactId>gt2-referencing</artifactId>
                <version>${gt.version}</version>
            </dependency>
            <dependency>
                <groupId>org.geotools</groupId>
                <artifactId>gt2-render</artifactId>
                <version>${gt.version}</version>
            </dependency>

            <!-- end geotools -->
            <!-- RichFaces -->
            <dependency>
                <groupId>org.richfaces.core</groupId>
                <artifactId>richfaces-core-impl</artifactId>
            </dependency>
            <dependency>
                <groupId>org.richfaces.ui</groupId>
                <artifactId>richfaces-components-ui</artifactId>
            </dependency>
            <!-- end RichFaces -->
           
            <dependency>
                <groupId>org.atmosphere</groupId>
                <artifactId>atmosphere-runtime</artifactId>
                <exclusions>
                    <exclusion>
                        <artifactId>slf4j-api</artifactId>
                        <groupId>org.slf4j</groupId>
                    </exclusion>
                </exclusions>
            </dependency>

     

    ---arquillian.xml ----------

     

    <?xml version="1.0" encoding="UTF-8"?>
    <arquillian xmlns="http://jboss.com/arquillian"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:glassfish-embedded="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3">

       <!-- Uncomment to have test archives exported to the file system for inspection -->
       <!--
       <engine>
          <deploymentExportPath>target/</deploymentExportPath>
       </engine>
       -->

       <glassfish-embedded:container>
          <glassfish-embedded:sunResourcesXml>src/test/resources-glassfish-embedded/sun-resources.xml</glassfish-embedded:sunResourcesXml>
       </glassfish-embedded:container> 

    </arquillian>