9 Replies Latest reply on Jul 13, 2010 11:49 AM by Philip Dudley

    TestNG Fails with Seam-Gen Project

    Charlie B Newbie

      Hi,


      As per the seam framework documentation, (37.3.1 Configuration) it says that if I created my project using Seam-Gen, then it should be ready for Unit and Integration testing using TestNG.


      However, I have been trying for over a week to get this to work and continue to fail.


      I think the problem lies with my persistence.xml and datasource.
      Do I need to copy the datasource xml file anywhere or do anything with it?
      Or should I only have to run the 'test' target in the ANT script?


      Please help.


      Here is the stack trace I am getting when running the tests:




      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=koncentrator
       -> <UNKNOWN>{Described:** UNRESOLVED Demands 'jboss.jca:name=koncentratorDatasource,service=DataSourceBinding **}
      
      
      *** CONTEXTS IN ERROR: Name -> Error
      
      <UNKNOWN> -> ** UNRESOLVED Demands 'jboss.jca:name=koncentratorDatasource,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.AbstractSeamTest.startJbossEmbeddedIfNecessary(AbstractSeamTest.java:1024)
           at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:915)
           at org.jboss.seam.mock.SeamTest.startSeam(SeamTest.java:58)
      ... Removed 15 stack frames
      
      Click to hide stack frames
      
      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=koncentrator
       -> <UNKNOWN>{Described:** UNRESOLVED Demands 'jboss.jca:name=koncentratorDatasource,service=DataSourceBinding **}
      
      
      *** CONTEXTS IN ERROR: Name -> Error
      
      <UNKNOWN> -> ** UNRESOLVED Demands 'jboss.jca:name=koncentratorDatasource,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.AbstractSeamTest.startJbossEmbeddedIfNecessary(AbstractSeamTest.java:1024)
           at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:915)
           at org.jboss.seam.mock.SeamTest.startSeam(SeamTest.java:58)
           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.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:607)
           at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:417)
           at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:154)
           at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:88)
           at org.testng.SuiteRunner.privateRun(SuiteRunner.java:284)
           at org.testng.SuiteRunner.run(SuiteRunner.java:204)
           at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:877)
           at org.testng.TestNG.runSuitesLocally(TestNG.java:842)
           at org.testng.TestNG.run(TestNG.java:751)
           at org.testng.TestNG.privateMain(TestNG.java:914)
           at org.testng.TestNG.main(TestNG.java:887)




      Here is my test persistence xml file:




      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Persistence deployment descriptor for dev profile -->
      <persistence 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" 
                   version="1.0">
                   
         <persistence-unit name="koncentrator" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>koncentratorDatasource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
               <property name="hibernate.hbm2ddl.auto" value="validate"/>
               <property name="hibernate.show_sql" value="false"/>
               <property name="hibernate.format_sql" value="true"/>
               <property name="hibernate.default_schema" value="CAIROTEST"/>
               <!-- Only relevant if Seam is loading the persistence unit (Java SE bootstrap) -->
               <property name="hibernate.transaction.manager_lookup_class" value="@transactionManagerLookupClass@"/>
            </properties>
         </persistence-unit>
          
      </persistence>



      Is it a problem with my datasource? What am i missing?


      Thanks in advance.

        • 1. Re: TestNG Fails with Seam-Gen Project
          Robert  Anderson Newbie
          if you are running on jdk 1.6 you have to add this option: -Dsun.lang.ClassLoader.allowArraySyntax=true

          I had this same problem.

          • 2. Re: TestNG Fails with Seam-Gen Project
            Charlie B Newbie

            Hi,


            Thanks for your response.
            But before I tried your solution, I made some progress of my own and now get the following error:


            EntityManagerFactory not found in JNDI : java:/koncentratorEntityManagerFactory


            Is this still related? Or do I need to do something else?


            Thanks for your help.

            • 3. Re: TestNG Fails with Seam-Gen Project
              Robert  Anderson Newbie
              Try to put this line on your persistence.xml:


              <property name="jboss.entity.manager.factory.jndi.name" value="java:/koncentratorEntityManagerFactory"/>
              • 4. Re: TestNG Fails with Seam-Gen Project
                Charlie B Newbie

                No that didn't work.


                I still get the same exception.


                These are all my relevant files.




                <?xml version="1.0" encoding="UTF-8"?>
                <!-- Persistence deployment descriptor for tests -->
                <persistence 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" 
                             version="1.0">
                             
                   <persistence-unit name="koncentrator" transaction-type="JTA">
                      <provider>org.hibernate.ejb.HibernatePersistence</provider>
                      <jta-data-source>java:/DefaultDS</jta-data-source>
                      <properties>
                         <property name="hibernate.hbm2ddl.auto" value="update"/>
                         <property name="hibernate.show_sql" value="true"/>
                         <property name="hibernate.cache.use_second_level_cache" value="false"/>
                         <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                      </properties>
                   </persistence-unit>
                    
                </persistence>





                <?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>koncentratorDatasource</jndi-name>
                      <use-java-context>false</use-java-context>
                      <connection-url>jdbc:oracle:thin:@porcdev02.StateWater.local:1521:cairo</connection-url>
                      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                      <user-name>cairotest</user-name>
                      <password>cairotest</password>
                   </local-tx-datasource>
                    
                </datasources>



                And snippet from components.xml




                <persistence:managed-persistence-context name="entityManager" auto-create="true"
                                          entity-manager-factory="@seamEmfRef@"
                                      persistence-unit-jndi-name="@puJndiName@"/>



                And this is in ANT:




                <condition property="seamEmfRef" value="#{entityManagerFactory}" else="#{null}">
                            <istrue value="${seamBootstrapsPu}"/>
                        </condition>
                        <condition property="puJndiName" value="#{null}" else="java:comp/env/${project.name}/pu">
                            <istrue value="${seamBootstrapsPu}"/>
                        </condition>



                Do I need to copy the Datasource anywhere before I can run TestNG?


                Thanks again for your help.

                • 5. Re: TestNG Fails with Seam-Gen Project
                  Charlie B Newbie

                  I seem to have solved the problem by putting




                  <property name="jboss.entity.manager.factory.jndi.name" value="java:/koncentratorEntityManagerFactory"/>




                  into my persistence.xml


                  and changing




                  <persistence:managed-persistence-context name="entityManager" auto-create="true"
                                            entity-manager-factory="@seamEmfRef@"
                                        persistence-unit-jndi-name="@puJndiName@"/>





                  to




                  <persistence:managed-persistence-context name="entityManager" auto-create="true"
                                            entity-manager-factory="@seamEmfRef@"
                                        persistence-unit-jndi-name="java:/koncentratorEntityManagerFactory"/>




                  The ANT script was setting my persistence-unit-jndi-name to java:comp/env/${project.name}/pu - which was not working.


                  Only problem is, this doesnt work when running my application normally in JBoss.
                  Is there a way around this? Or do i just have to specify diff properties for each env?


                  Thanks

                  • 6. Re: TestNG Fails with Seam-Gen Project
                    Charlie B Newbie

                    Hi,


                    I seem to have everything working and im on the right track, but im getting a weird error and have no reason why.




                    ERROR JDBCExceptionReporter - invalid schema name: CAIROTEST in statement [select * from ( select reading0_.VDATE as VDATE5_, reading0_.SITEID as SITEID5_, reading0_.VTIME as VTIME5_, reading0_.VARID as VARID5_, reading0_.SVALUE as SVALUE5_ from CAIROTEST.MANOPSREAD reading0_ where lower(reading0_.VARID) like lower(?||'%') ) where rownum <= ?]




                    My Persistence xml is below. The schema im using is CAIROTEST and specified. Why would this be happening?



                    <?xml version="1.0" encoding="UTF-8"?>
                    <!-- Persistence deployment descriptor for tests -->
                    <persistence 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" 
                                 version="1.0">
                                 
                       <persistence-unit name="koncentrator" transaction-type="JTA">
                          <provider>org.hibernate.ejb.HibernatePersistence</provider>
                          <jta-data-source>java:/DefaultDS</jta-data-source>
                          <properties>
                                <property name="jboss.entity.manager.factory.jndi.name" value="java:/koncentratorEntityManagerFactory"/>
                                <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
                             <property name="hibernate.hbm2ddl.auto" value="validate"/>
                             <property name="hibernate.show_sql" value="true"/>
                             <property name="hibernate.cache.use_second_level_cache" value="false"/>
                             <property name="hibernate.default_schema" value="CAIROTEST"/>
                             <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                          </properties>
                       </persistence-unit>
                        
                    </persistence>




                    • 7. Re: TestNG Fails with Seam-Gen Project
                      lance stine Newbie

                      Have you tried adding


                      CREATE SCHEMA CAIROTEST;


                      to your import-test.sql?

                      • 8. Re: TestNG Fails with Seam-Gen Project
                        Philip Dudley Newbie

                        Charlie Barjel wrote on Jan 15, 2010 01:00:


                        Only problem is, this doesnt work when running my application normally in JBoss.
                        Is there a way around this? Or do i just have to specify diff properties for each env?



                        I can get to a similar place if I create two different properties. Like Charlie asked, is it common practice to have different properties for each environment?


                        Thank you,
                        Phil

                        • 9. Re: TestNG Fails with Seam-Gen Project
                          Philip Dudley Newbie

                          Philip Dudley wrote on Jul 12, 2010 12:53:



                          Charlie Barjel wrote on Jan 15, 2010 01:00:


                          Only problem is, this doesnt work when running my application normally in JBoss.
                          Is there a way around this? Or do i just have to specify diff properties for each env?



                          I can get to a similar place if I create two different properties. Like Charlie asked, is it common practice to have different properties for each environment?

                          Thank you,
                          Phil


                          I am still wondering the same thing. Is it common practice to have different properties for each environment?


                          Any input would be greatly appreciated.
                          Thank you,
                          Phil