6 Replies Latest reply on Jun 30, 2010 8:01 AM by Alfredo Alfredo

    TestNG: SeamTest on tomcat: problems

    Stijn Cremers Novice

      I have written a very simple TestClass that extends from SeamTest.
      But when i try to execute it, i got several errors.


      This is my TestClass:


      public class PotentialCostChangesAction extends SeamTest{
                      
                      @Test
                      public void testApplicationForm() throws Exception {
                              System.out.println("blabla");
      
                      }
      
      }
      



      The exception i get is


      ERROR org.jboss.kernel.plugins.dependency.AbstractKernelController
      Error installing to Described: name=BeanDeployer state=PreInstall
      java.lang.RuntimeException: java.lang.reflect.UndeclaredThrowableException
              at org.jboss.aop.util.ClassInfoMethodHashing.methodHash(ClassInfoMethodHashing.java:70)
              at org.jboss.aop.util.ClassInfoMethodHashing.addDeclaredMethods(ClassInfoMethodHashing.java:169)
              at org.jboss.aop.util.ClassInfoMethodHashing.populateMethodTables(ClassInfoMethodHashing.java:182)
              at org.jboss.aop.util.ClassInfoMethodHashing.populateMethodTables(ClassInfoMethodHashing.java:181)
              at org.jboss.aop.util.ClassInfoMethodHashing.populateMethodTables(ClassInfoMethodHashing.java:181)
              at org.jboss.aop.util.ClassInfoMethodHashing.populateMethodTables(ClassInfoMethodHashing.java:181)
              at org.jboss.aop.util.ClassInfoMethodHashing.populateMethodTables(ClassInfoMethodHashing.java:181)
              at org.jboss.aop.util.ClassInfoMethodHashing.populateMethodTables(ClassInfoMethodHashing.java:181)
              at org.jboss.aop.util.ClassInfoMethodHashing.getMethodMap(ClassInfoMethodHashing.java:188)
              at org.jboss.aop.microcontainer.integration.AOPDependencyBuilder.getMethodAnnotationDependencies(AOPDependencyBuilder.java:197)
              at org.jboss.aop.microcontainer.integration.AOPDependencyBuilder.getAnnotationDependencies(AOPDependencyBuilder.java:152)
              at org.jboss.aop.microcontainer.integration.AOPDependencyBuilder.getDependencies(AOPDependencyBuilder.java:130)
              at org.jboss.classadapter.plugins.BasicClassAdapter.getDependencies(BasicClassAdapter.java:80)
              at org.jboss.beans.info.plugins.AbstractBeanInfo.getDependencies(AbstractBeanInfo.java:211)
              at org.jboss.kernel.plugins.dependency.DescribeAction.installActionInternal(DescribeAction.java:53)
              at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.installAction(KernelControllerContextAction.java:135)
              at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.installAction(KernelControllerContextAction.java:46)
              at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
              at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
              at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
              at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:327)
              at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1309)
              at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:734)
              at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:862)
              at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:784)
              at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:574)
              at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:398)
              at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:309)
              at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:279)
              at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:130)
              at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:96)
              at org.jboss.embedded.Bootstrap.deployBaseBootstrapUrl(Bootstrap.java:130)
              at org.jboss.embedded.Bootstrap.bootstrapURL(Bootstrap.java:142)
              at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:183)
              at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:195)
              at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:11)
              at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1041)
              at org.jboss.seam.mock.BaseSeamTest.startSeam(BaseSeamTest.java:935)
              at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:923)
              at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
              at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:398)
              at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
              at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:82)
              at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:167)
              at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
              at org.testng.TestRunner.runWorkers(TestRunner.java:712)
              at org.testng.TestRunner.privateRun(TestRunner.java:582)
              at org.testng.TestRunner.run(TestRunner.java:477)
              at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
              at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
              at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
              at org.testng.SuiteRunner.run(SuiteRunner.java:198)
              at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823)
              at org.testng.TestNG.runSuitesLocally(TestNG.java:790)
              at org.testng.TestNG.run(TestNG.java:708)
              at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
              at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
      Caused by: java.lang.reflect.UndeclaredThrowableException
              at org.jboss.reflect.plugins.ArrayInfoImpl.getType(ArrayInfoImpl.java:103)
              at org.jboss.reflect.plugins.ClassInfoImpl.isArray(ClassInfoImpl.java:495)
              at org.jboss.aop.util.ClassInfoMethodHashing.getTypeString(ClassInfoMethodHashing.java:149)
              at org.jboss.aop.util.ClassInfoMethodHashing.methodHash(ClassInfoMethodHashing.java:53)
              ... 61 more
      Caused by: java.lang.ClassNotFoundException: [Ljava.lang.Class;
              at java.net.URLClassLoader$1.run(Unknown Source)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(Unknown Source)
              at java.lang.ClassLoader.loadClass(Unknown Source)
              at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
              at java.lang.ClassLoader.loadClass(Unknown Source)
              at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.resolveComplexTypeInfo(IntrospectionTypeInfoFactoryImpl.java:367)
              at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.getTypeInfo(IntrospectionTypeInfoFactoryImpl.java:344)
              at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory.getTypeInfo(IntrospectionTypeInfoFactory.java:54)
              at org.jboss.reflect.plugins.ArrayInfoImpl.getType(ArrayInfoImpl.java:99)
              ... 64 more
      


      I'm using tomcat as application server.


      Greetz

        • 1. Re: TestNG: SeamTest on tomcat: problems
          Marcio Endo Newbie

          From this last bit:


          Caused by: java.lang.ClassNotFoundException: [Ljava.lang.Class;
                  at java.net.URLClassLoader$1.run(Unknown Source)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at java.net.URLClassLoader.findClass(Unknown Source)
                  at java.lang.ClassLoader.loadClass(Unknown Source)
                  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
                  at java.lang.ClassLoader.loadClass(Unknown Source)
          



          It seems your using a Java6 runtime.
          There is a workaround for using a Java6 runtime with the embedded container (just look for it in the forums), but I guess the easiest way is just to use a Java5 runtime.

          • 2. Re: TestNG: SeamTest on tomcat: problems
            Stijn Cremers Novice

            Thanks, it solved my first problem... but isn't working yet....


            Now, i get the following error:


            FAILED CONFIGURATION: @BeforeClass init
            org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
            
            *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
            
            persistence.units:unitName=StrategicPurchaseDB
             -> <UNKNOWN>{Described:** UNRESOLVED Demands 'jboss.jca:name=comp/env/jdbc/StrategicPurchaseDBDatasource,service=DataSourceBinding **}
            
            
            *** CONTEXTS IN ERROR: Name -> Error
            
            <UNKNOWN> -> ** UNRESOLVED Demands 'jboss.jca:name=comp/env/jdbc/StrategicPurchaseDBDatasource,service=DataSourceBinding **
            
            
                 at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:576)
                 at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:559)
                 at org.jboss.embedded.DeploymentGroup.process(DeploymentGroup.java:128)
                 at org.jboss.embedded.Bootstrap.deployResourceBases(Bootstrap.java:289)
                 at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:15)
                 at org.jboss.seam.mock.BaseSeamTest.startJbossEmbeddedIfNecessary(BaseSeamTest.java:1041)
                 at org.jboss.seam.mock.BaseSeamTest.startSeam(BaseSeamTest.java:935)
                 at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:923)
                 at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
            ... Removed 22 stack frames
            SKIPPED CONFIGURATION: @BeforeMethod begin
            SKIPPED CONFIGURATION: @AfterMethod end
            SKIPPED CONFIGURATION: @AfterClass cleanup
            SKIPPED: testApplicationForm
            
            
            



            Are there any good site with a full tutorial about testing with seam?


            Thanks !

            • 3. Re: TestNG: SeamTest on tomcat: problems
              Stijn Cremers Novice

              I found the cause of the exception:


              The persistence context can't find the datasource.
              Because i'm using tomcat, i need to refer to the datasource my com/env/jdbc/datasource. But when using testNG, that jndi isn't set.


              This is my persistence.xml


              <?xml version="1.0" encoding="UTF-8"?>
              <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                <persistence-unit name="StrategicPurchaseDB" transaction-type="RESOURCE_LOCAL">
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <jta-data-source>java:comp/env/jdbc/StrategicPurchaseDBDatasource</jta-data-source>
                  <properties>
                       <property name="hibernate.show_sql" value="true"/>
                         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                         <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
                  </properties>
                </persistence-unit>
              </persistence>
              



              and this is my test datasource:


              <?xml version="1.0" encoding="UTF-8"?>
              
              <!DOCTYPE datasources
                  PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
                  "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
                  
              <datasources>
                 
                 <local-tx-datasource>
                    <jndi-name>comp/env/jdbc/StrategicPurchaseDBDatasource</jndi-name>
                    <connection-url>jdbc:sqlserver://xx</connection-url>
                    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
                    <user-name>xx</user-name>
                    <password>xx</password>
              
                 </local-tx-datasource>
                  
              </datasources>
              



              As you can see: those jndi names don't correspond :(.


              • 4. Re: TestNG: SeamTest on tomcat: problems
                Stijn Cremers Novice

                I have found all the problems and solved them.
                But i'm not very happy with the result.


                This is my currenty persistence.xml


                <?xml version="1.0" encoding="UTF-8"?>
                
                <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                  <persistence-unit name="StrategicPurchaseDB" transaction-type="RESOURCE_LOCAL">
                    <jta-data-source>java:comp/env/jdbc/StrategicPurchaseDBDatasource</jta-data-source>
                    <properties>
                         <property name="hibernate.show_sql" value="true"/>
                           <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                           <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
                    </properties>
                  </persistence-unit>
                </persistence>
                
                <!-- TESTNG -->
                <!-- persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                <persistence-unit name="StrategicPurchaseDB" transaction-type="JTA">
                    <provider>org.hibernate.ejb.HibernatePersistence</provider>
                    <jta-data-source>java:/StrategicPurchaseDBDatasource</jta-data-source>
                    <properties>
                         <property name="hibernate.show_sql" value="true"/>
                           <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                           <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
                           <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                    </properties>
                  </persistence-unit>
                </persistence -->



                As you can see i have one persistence unit for tomcat and one for testng, so i have to comment always one before running :-(.


                Is there a better solutions for this?


                I need to do the same for the components.xml


                • 5. Re: TestNG: SeamTest on tomcat: problems
                  Pete Muir Master

                  Use ant to copy the correct one into your test structure as persistence.xml or use ant filtering.

                  • 6. Re: TestNG: SeamTest on tomcat: problems
                    Alfredo Alfredo Newbie

                    There is another way without Across the ant?


                    Thank,