1 2 Previous Next 22 Replies Latest reply on Jan 20, 2012 1:34 PM by diegosantiviago

    TestNG & Maven: How to configure it correctly

      Hi all,


      it could be a longer post, but I hope you read it.


      I am fighting with this problem for a long time, but I don't know where is the problem.
      Therefore I have tried to divide it into several sections:



      The Goal


      I want to execute a simply test(TestNG) with Maven. The test should be executed in the JBoss Embedded. My application server is Glassfish v2.1 b60.


      The structure of my project


      My Maven-project is divided into four projects: MyProj-ALL, MyProj-EAR, MyProj-EJB, MyProj-WAR. But MyProj-EJB is the place where my test will be created and executed.


      Step1: Executing the test with the SeamGen2.1.2 generated project


      I wanted to be ensure, that the test will be running correctly. Because of this reason I created a project with SeamGen2.1.2.
      SeamGen2.1.2 helps you so much to get a running project quickly. I created an easy TestNG-test to test the database.

      Here is the persistence-test.xml:


      <?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">
           <!-- In-memory HSQLDB -->        
         <persistence-unit name="helloWorldTest" transaction-type="RESOURCE_LOCAL">
         
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <non-jta-data-source>java:/DefaultDS</non-jta-data-source>
            <properties>
               <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.cache.use_second_level_cache" value="false"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/helloworldEntityManagerFactory"/>
            </properties>
         </persistence-unit>
          
      </persistence>



      The test was running correctly.
      Unfortunately SeamGen uses Ant, but I need to configure it with Maven. To keep in mind the Ant task, here it is:


       <target name="test" depends="buildtest" description="Run the tests">
              <condition property="incompatible.jdk">
                  <and>
                      <equals arg1="${ant.java.version}" arg2="1.6"/>
                      <not><available classname="javax.xml.bind.JAXB"/></not>
                  </and>
              </condition>
              <fail if="incompatible.jdk">You are using an incompatible JDK 6. Please use Sun JDK 6 Update 4 (1.6.0_04) or newer or use Open JDK 6.</fail>
              <taskdef resource="testngtasks" classpath="${testng.jar}"/>
              <path id="test.path">
                  <path path="${test.dir}"/>
                  <fileset dir="${lib.dir}/test">
                      <include name="*.jar"/>
                  </fileset>
                  <path path="${bootstrap.dir}"/>
                  <path refid="build.classpath"/>
              </path>
              <testng outputdir="${basedir}/test-report">
                  <jvmarg line="-Djava.endorsed.dirs=${endorsed.dir}"/>
                  <jvmarg line="-Dsun.lang.ClassLoader.allowArraySyntax=true"/>
                  <classpath refid="test.path"/>
                  <xmlfileset dir="${test.dir}" includes="*Test.xml"/>
              </testng>
          </target>
      
          <target name="javadoc" depends="compile">
              <mkdir dir="${dist.dir}/apidoc"/>
              <javadoc classpathref="build.classpath" destdir="${dist.dir}/apidoc" use="true" protected="true" version="true" windowtitle="${project.name} API Documentation" doctitle="${project.name} API Documentation" link="http://java.sun.com/j2se/5.0/docs/api">
                  <packageset dir="${src.action.dir}" defaultexcludes="yes">
                      <include name="*/**"/>
                  </packageset>
                  <packageset dir="${src.model.dir}" defaultexcludes="yes">
                      <include name="*/**"/>
                  </packageset>
              </javadoc>
          </target>



      Everything is running correctly. Lets try it with Maven now.


      Step2: Configuration of the MyProjEJB to execute a TestNG-test with Maven


      I copied the bootstrap-folder and the persistence-test.xml of the generated SeamGen-project to the MyProjEJB.
      Here is the structure of the MyProjEJB:



      MyProjEJB
      ->bootstrap
                 ->conf
                       ->messaging-roles.properties
                       ->messaging-users.properties
                 ->bootstrap-beans.xml
                 ->jbossjts-properties.xml
                 ->jboss-service.xml
                 ->login-config.xml
                 ->data
                       ->hypersonic
                                   ->localDB.lck
                                   ->localDB.log
                                   ->localDB.properties
                                   ->localDB.script
                 ->deploy
                       ->messaging
                                   ->connection-factories-service.xml
                                   ->destinations-service.xml
                                   ->hsqldb-persistence-service.xml
                                   ->jms-ds.xml
                                   ->legacy-service.xml
                                   ->messaging-service.xml
                                   ->remoting-service.xml
                       ->ejb3-interceptors-aop.xml
                       ->hsqldb-ds.xml
                       ->jboss-local-jdbc.rar
                       ->jboss-xa-jdbc.rar
                       ->jms-ra.rar
                       ->remoting.service.xml
                 ->deployers
                       ->aspect-deployer-beans.xml
                       ->ejb3-deployers-beans.xml
                       ->ejb.deployer-beans.xml
                       ->jboss-aspect-library-beans.xml
                       ->jca-deployers-beans.xml
                       ->security-deployer-beans.xml
                 ->META-INF
                       ->persistence.properties
                 ->tmp
                 ->commons-logging.properties
                 ->jndi.properties
                 ->log4j.xml
      ->lib (libs of the generated SeamGen-project)
      ->src
                 ->main
                       ->java(Beans and interfaces inside) 
                       ->resources
                                   ->META-INF
                                             ->ejb-jar.xml
                                             ->persistence.xml(for the application)
                 ->test
                 ->java
                       ->MyTest.java
                 ->resources
                           ->META-INF
                                             ->persistence.properties
                                             ->persistence-test.xml(for the test)
      ->target
                 ->classes
                 ->surefire-reports
                 ->test-classes
      ->pom.xml



      Content of the surefire of the pom.xml:


      <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                <testSourceDirectory>${myproj.home}/myproj-ejb/src/test</testSourceDirectory>
                <testClassesDirectory>${myproj.home}/myproj-ejb/target/test-classes</testClassesDirectory>
                
                     <additionalClasspathElements>
                          <!-- Load the bootstrap -->
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/conf/bootstrap-beans.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/conf/jbossjta-properties.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/conf/jboss-service.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/conf/login-config.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/data/hypersonic/localDB.lck</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/data/hypersonic/localDB.log</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/data/hypersonic/localDB.properties</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/data/hypersonic/localDB.script</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/messaging/connection-factories-service.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/messaging/destinations-service.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/messaging/hsqldb-persistence-service.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/messaging/jms-ds.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/messaging/legacy-service.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/messaging/messaging-service.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/messaging/remoting-service.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/ejb3-interceptors-aop.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/hsqldb-ds.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/jboss-local-jdbc.rar</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/jboss-xa-jdbc.rar</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/jms-ra.rar</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deploy/remoting-service.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deployers/aspect-deployer-beans.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deployers/ejb3-deployers-beans.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deployers/jboss-aspect-library-beans.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deployers/jca-deployers-beans.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deployers/metadata-beans.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/deployers/security-deployer-beans.xml</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/META-INF/persistence.properties</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/commons-logging.properties</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/jndi.properties</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/bootstrap/log4j.xml</additionalClasspathElement>
                          <!-- Load the libs -->
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/jboss-embedded-all.jar</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/hibernate-all.jar</additionalClasspathElement>
                          <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/thirdparty-all.jar</additionalClasspathElement>
                              <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/jboss-embedded-api.jar</additionalClasspathElement>
                                 <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/jboss-seam.jar</additionalClasspathElement>
                                 <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/jboss-deployers-client-spi.jar</additionalClasspathElement>
                                 <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/jboss-deployers-core-spi.jar</additionalClasspathElement>
                                 <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/jboss-el.jar</additionalClasspathElement>
                                 <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/activation.jar</additionalClasspathElement>
                                 <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/el-api.jar</additionalClasspathElement>
                                 <additionalClasspathElement>${myproj.home}/myproj-ejb/lib/jsf-api.jar</additionalClasspathElement>
                     </additionalClasspathElements>
                     
                     <skipTests>false</skipTests>
                     <testFailureIgnore>false</testFailureIgnore>
                     <argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true -Djava.endorsed.dirs=${project.build.testOutputDirectory}/endorsed</argLine>     
                </configuration>
                  <executions>
                     <execution>
                          <id>surefire-it</id>
                          <phase>integration-test</phase>
                          <goals>
                               <goal>test</goal>
                          </goals>
                     </execution>
                </executions>
           </plugin>



      Finally the classpath:


      <?xml version="1.0" encoding="UTF-8"?>
      <classpath>
           <classpathentry kind="src" output="target/classes" path="src/main/java"/>
           <classpathentry kind="src" path="bootstrap"/>
           <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
           <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
           <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
           <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_11"/>
           <classpathentry kind="output" path="target/classes"/>
      </classpath>



      Step3: Executing the test with Maven test


      If I execute the test with Maven test I get the following error:



      [DEBUG] Test Classpath :
      [DEBUG]   C:\Projects\My_Project\main\Sourcen_maven\myproj-ejb\target\test-classes
      [DEBUG]   C:\Projects\My_Project\main\Sourcen_maven\myproj-ejb\target\classes
      [DEBUG]   c:\Projects\javalibs\MavenRepository\junit\junit\4.0\junit-4.0.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\log4j\log4j\1.2.14\log4j-1.2.14.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-all\beta3.SP4\jboss-embedded-all-beta3.SP4.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-api\beta3.SP4\jboss-embedded-api-beta3.SP4.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-client-spi\2.0.0.Beta6\jboss-deployers-client-spi-2.0.0.Beta6.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-core-spi\2.0.0.Beta6\jboss-deployers-core-spi-2.0.0.Beta6.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\hibernate-all\beta3.SP4\hibernate-all-beta3.SP4.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\thirdparty-all\beta3.SP4\thirdparty-all-beta3.SP4.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\apache\axis\axis\1.4\axis-1.4.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\apache\axis\axis-jaxrpc\1.4\axis-jaxrpc-1.4.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\ejb\ejb-api\3.0\ejb-api-3.0.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\faces\jsf-api\1.2_09-BETA1\jsf-api-1.2_09-BETA1.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam\2.1.1.GA\jboss-seam-2.1.1.GA.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\el\jboss-el\1.0_02.CR2\jboss-el-1.0_02.CR2.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\el\el-api\1.0\el-api-1.0.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\org\testng\testng\5.6\testng-5.6.jar
      [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/conf/bootstrap-beans.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/conf/jbossjta-properties.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/conf/jboss-service.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/conf/login-config.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/data/hypersonic/localDB.lck
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/data/hypersonic/localDB.log
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/data/hypersonic/localDB.properties
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/data/hypersonic/localDB.script
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/messaging/connection-factories-service.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/messaging/destinations-service.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/messaging/hsqldb-persistence-service.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/messaging/jms-ds.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/messaging/legacy-service.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/messaging/messaging-service.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/messaging/remoting-service.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/ejb3-interceptors-aop.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/hsqldb-ds.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/jboss-local-jdbc.rar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/jboss-xa-jdbc.rar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/jms-ra.rar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deploy/remoting-service.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deployers/aspect-deployer-beans.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deployers/ejb3-deployers-beans.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deployers/jboss-aspect-library-beans.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deployers/jca-deployers-beans.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deployers/metadata-beans.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/deployers/security-deployer-beans.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/META-INF/persistence.properties
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/commons-logging.properties
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/jndi.properties
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/bootstrap/log4j.xml
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/jboss-embedded-all.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/hibernate-all.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/thirdparty-all.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/jboss-embedded-api.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/jboss-seam.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/jboss-deployers-client-spi.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/jboss-deployers-core-spi.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/jboss-el.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/activation.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/el-api.jar
      [DEBUG]   C:/Projects/My_Project/main/Sourcen_maven/myproj-ejb/lib/jsf-api.jar
      [DEBUG] Setting system property [user.dir]=[C:\Projects\My_Project\main\Sourcen_maven\myproj-ejb]
      [DEBUG] Setting system property [localRepository]=[c:/Projects/javalibs/MavenRepository]
      [DEBUG] Setting system property [basedir]=[C:\Projects\My_Project\main\Sourcen_maven\myproj-ejb]
      [DEBUG] Using JVM: C:\Programme\Java\jdk1.6.0_11\jre\bin\java
      [INFO] Surefire report directory: C:\Projects\My_Project\main\Sourcen_maven\myproj-ejb\target\surefire-reports
      Forking command line: cmd.exe /X /C "C:\Programme\Java\jdk1.6.0_11\jre\bin\java -Dsun.lang.ClassLoader.allowArraySyntax=true -Djava.endorsed.dirs=C:\Projects\My_Project\main\Sourcen_maven\myproj-ejb\target\test-classes/endorsed -jar C:\DOKUME~1\myproj\LOKALE~1\Temp\surefirebooter7578639955679396343.jar C:\DOKUME~1\myproj\LOKALE~1\Temp\surefire7457818046451040985tmp C:\DOKUME~1\myproj\LOKALE~1\Temp\surefire4258852975319354709tmp"
      
      -------------------------------------------------------
       T E S T S
      -------------------------------------------------------
      Running TestSuite
      [Parser] Running:
        Command line suite
      
      Tests run: 8, Failures: 1, Errors: 0, Skipped: 7, Time elapsed: 17.906 sec <<< FAILURE!
      
      Results :
      
      Failed tests: 
        startSeam(MyTest)



      Here are the details:


      CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
      
      jboss.j2ee:jar=classes,name=AddressBookService,service=EJB3
       -> <UNKNOWN>{Described: UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MYPROJ }
      
      jboss.j2ee:jar=classes,name=KeyTabAllocationBean,service=EJB3
       -> <UNKNOWN>{Described: UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MYPROJ }
      
      jboss.j2ee:jar=classes,name=KeyTabService,service=EJB3
       -> <UNKNOWN>{Described: UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MYPROJ }
      
      jboss.j2ee:jar=classes,name=PersonAnlegenBean,service=EJB3
       -> <UNKNOWN>{Described: UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MYPROJ }
      
      jboss.j2ee:jar=classes,name=ReleaseManagementService,service=EJB3
       -> <UNKNOWN>{Described: UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MYPROJ }
      
      persistence.units:jar=classes.jar,unitName=MYPROJ
       -> <UNKNOWN>{Described: UNRESOLVED Demands 'jboss.jca:name=jdbc/MYPROJ,service=DataSourceBinding }
      
      
       CONTEXTS IN ERROR: Name -> Error
      
      <UNKNOWN> ->  UNRESOLVED Demands 'jboss.jca:name=jdbc/myproj,service=DataSourceBinding 
      
      ]]>
                  </message>
                  <full-stacktrace>
                    <![CDATA[org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      
       CONTEXTS MISSING DEPENDENCIES: Name -&gt; Dependency{Required State:Actual State}
      
      jboss.j2ee:jar=classes,name=BeanA,service=EJB3
       -&gt; &lt;UNKNOWN&gt;{Described: UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MYPROJ }
      
      jboss.j2ee:jar=classes,name=BeanB,service=EJB3
       -&gt; &lt;UNKNOWN&gt;{Described: UNRESOLVED Demands 'persistence.units:jar=classes.jar,unitName=MYPROJ }
      
      persistence.units:jar=classes.jar,unitName=MYPROJ
       -&gt; &lt;UNKNOWN&gt;{Described: UNRESOLVED Demands 'jboss.jca:name=jdbc/myproj,service=DataSourceBinding }
      
      
       CONTEXTS IN ERROR: Name -&gt; Error
      
      &lt;UNKNOWN&gt; -&gt;  UNRESOLVED Demands 'jboss.jca:name=jdbc/myproj,service=DataSourceBinding 



      The problem


      As you see: There is a problem with the persistence.xml of the project (not of the test).
      MyTest.java is a very easy test and don't need the persistence.xml of the project:


      public class ReleaseDBTest extends SeamTest
      {
        @Test
        public void sayHello() throws Exception
        {
          System.out.println("Hello");
          assert true;
        }
        @Test
        public EntityManager createEntityManager() throws Exception {
          EntityManagerFactory emf = Persistence
              .createEntityManagerFactory("helloWorldTest");
          EntityManager em = emf.createEntityManager();
          assert em.isOpen();
          return em;
        }
      }




      In my opinion the configuration of the surefire-plugin is not correct.


      Thanks for reading.
      I hope you can give me a hint how to solve this problem.



      Regards

        • 1. Re: TestNG & Maven: How to configure it correctly
          dan.j.allen

          I know the question about Maven 2 and SeamTest has come up a lot on this forum. I'll present a solution to you here, but note that there are many ways to solve this problem.


          First, you do not need to specify every single file in the bootstrap directory as an additional classpath entry. Just the directory will do. I tend to put this in src/test/bootstrap.


          If you are executing Maven with JDK 6, do not forget the -D-Dsun.lang.ClassLoader.allowArraySyntax=true argline!


          Another very important tip that I have found is that you should try to ensure that Embedded JBoss appears at the beginning of the classpath! Otherwise, strange classloading issues may occur. You move it to the front by declaring the dependencies for Embedded JBoss first. One way to find out how Maven is executing Test NG is to use the <useManifestOnlyJar>false</useManifestOnlyJar> in the surefire plugin configuration and execute Maven with -X.


          You may or many not need to fork testng. I tend to prefer to fork since it cleanly separates the test run with the Maven build. If you can get away without forking, go ahead.


          Here is a barebones Maven 2 file that supports tests that extend SeamTest. Note that I don't have all the dependencies setup right to create a deployable WAR, which is typically the trickiest part of using Maven.


          <?xml version="1.0"?>
          <project xmlns="http://maven.apache.org/POM/4.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
              <parent>
                  <groupId>org.jboss.seam</groupId>
                  <artifactId>parent</artifactId>
                  <version>2.1.1.GA</version>
              </parent>
              <modelVersion>4.0.0</modelVersion>
              <groupId>com.domain.project</groupId>
              <artifactId>project-webapp</artifactId>
              <version>1.0-SNAPSHOT</version>
              <packaging>war</packaging>
              <name>Seam Maven 2 Starter Project</name>
              <description>A starter Seam project using a Maven 2 build. Configured to support functional tests based on SeamTest</description>
              <build>
                  <defaultGoal>package</defaultGoal>
                  <finalName>project</finalName>
                  <plugins>
                      <plugin>
                          <artifactId>maven-compiler-plugin</artifactId>
                          <version>RELEASE</version>
                          <configuration>
                              <source>1.5</source>
                              <target>1.5</target>
                          </configuration>
                      </plugin>
                      <plugin>
                          <artifactId>maven-surefire-plugin</artifactId>
                          <version>2.4.3</version>
                          <configuration>
                              <additionalClasspathElements>
                                  <additionalClasspathElement>${basedir}/src/test/bootstrap</additionalClasspathElement>
                              </additionalClasspathElements>
                              <forkMode>once</forkMode>
                              <jvm>${user.home}/opt/java-6-sun/bin/java</jvm>
                              <argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
                              <includes>
                                  <include>**/*Test.java</include>
                              </includes>
                          </configuration>
                      </plugin>
                  </plugins>
              </build>
              <repositories>
                  <repository>
                      <id>repository.jboss.org</id>
                      <url>http://repository.jboss.org/maven2</url>
                  </repository>
                  <repository>
                      <id>central</id>
                      <url>http://repo1.maven.org/maven2</url>
                  </repository>
              </repositories>
              <dependencyManagement>
                  <dependencies>
                      <!-- JTA 1.1 is actually available in the repositories -->
                      <dependency>
                          <groupId>javax.transaction</groupId>
                          <artifactId>jta</artifactId>
                          <version>1.1</version>
                          <scope>provided</scope>
                      </dependency>
                  </dependencies>
              </dependencyManagement>
              <dependencies>
                  <!-- Embedded JBoss dependencies
                       These make me a tad nervous because there are duplicate libraries on the test classpath.
                       However, Maven gives you no way to tare the classpath to zero and start fresh. -->
                  <dependency>
                      <groupId>org.jboss.seam.embedded</groupId>
                      <artifactId>jboss-embedded-all</artifactId>
                      <version>beta3</version>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.seam.embedded</groupId>
                      <artifactId>hibernate-all</artifactId>
                      <version>beta3</version>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.seam.embedded</groupId>
                      <artifactId>thirdparty-all</artifactId>
                      <version>beta3</version>
                      <scope>test</scope>
                  </dependency>
                  <!-- /Embedded JBoss dependencies -->
                  <dependency>
                      <groupId>javax.servlet</groupId>
                      <artifactId>servlet-api</artifactId>
                      <version>2.5</version>
                      <scope>provided</scope>
                  </dependency>
                  <dependency>
                      <groupId>javax.el</groupId>
                      <artifactId>el-api</artifactId>
                      <version>1.0</version>
                      <scope>provided</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.el</groupId>
                      <artifactId>jboss-el</artifactId>
                      <scope>provided</scope>
                  </dependency>
                  <dependency>
                      <groupId>com.sun.facelets</groupId>
                      <artifactId>jsf-facelets</artifactId>
                      <scope>runtime</scope>
                  </dependency>
                  <dependency>
                      <groupId>javax.faces</groupId>
                      <artifactId>jsf-api</artifactId>
                      <scope>provided</scope>
                  </dependency>
                  <dependency>
                      <groupId>javax.faces</groupId>
                      <artifactId>jsf-impl</artifactId>
                      <scope>provided</scope>
                  </dependency>
                  <dependency>
                      <groupId>javax.persistence</groupId>
                      <artifactId>persistence-api</artifactId>
                      <scope>provided</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-validator</artifactId>
                      <scope>compile</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.seam</groupId>
                      <artifactId>jboss-seam</artifactId>
                      <type>ejb</type>
                      <scope>compile</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.seam</groupId>
                      <artifactId>jboss-seam-debug</artifactId>
                      <scope>runtime</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.seam</groupId>
                      <artifactId>jboss-seam-ui</artifactId>
                      <scope>runtime</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.richfaces.framework</groupId>
                      <artifactId>richfaces-api</artifactId>
                      <scope>runtime</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.richfaces.ui</groupId>
                      <artifactId>richfaces-ui</artifactId>
                      <scope>runtime</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.testng</groupId>
                      <artifactId>testng</artifactId>
                      <version>5.6</version>
                      <scope>test</scope>
                  </dependency>
              </dependencies>
          </project>

          • 2. Re: TestNG & Maven: How to configure it correctly

            Thanks Dan for the answer.
            I've tried your solution, unfortunately without any success.


            To tell the truth: I don't know where is the problem, because if I'm executing the test with the TestNG Eclipse plugin without any problem.


            I have a lib folder which are the important jars.


            This is my running configuration with the TestNG plugin:


            Bootstrap Entries (jars):


            el-api
            jboss-deployers-client-spi
            jboss-deployers-core-spi
            jboss-el
            jboss-embedded-all
            jboss-embedded-api
            jboss-seam
            jsf-api
            thirdparty-all




            User Entries:
            bootstrap folder


            If I use the default configuration I get exactly the same problem as I'am executing the test with Maven.


            Here is my new pom.xml of the ejb-project:



            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
            
              <parent>
                <groupId>com.mypackage</groupId>
                <artifactId>myproject-all</artifactId>
                <version>${myproject.version}</version>
              </parent>
            
              <!-- Allgemeine Einstellungen -->
              <modelVersion>4.0.0</modelVersion>
              <groupId>com.mypackage</groupId>
              <artifactId>myproject-ejb</artifactId>
              <packaging>ejb</packaging>
              <name>MYPROJECT EJB</name>
            
              <build>
                <!-- resources>
                  <resource>
                    <directory>${myproject.home}/${myproject.release}/src/main/resources</directory>
                    <includes>
                      <include>**/*</include>
                    </includes>
                    <filtering>true</filtering>
                  </resource>
                </resources-->
            
                <plugins>
                  <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-ejb-plugin</artifactId>
                    <configuration>
                      <ejbVersion>3.0</ejbVersion>
                      <generateClient>true</generateClient>
                      <archive>
                        <manifest>
                          <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                          <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                          <addClasspath>true</addClasspath>
                          <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                        <manifestEntries>
                          <Class-Path>lib/myproject-server.jar</Class-Path>
                        </manifestEntries>            
                      </archive>
                    </configuration>
                  </plugin>
            
                 <!-- Surefire  -->
                 <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <version>2.4.3</version>
                      <configuration>
                                     <useManifestOnlyJar>false</useManifestOnlyJar>
                                <additionalClasspathElements>
                                    <additionalClasspathElement>${myproject.home}/myproject-ejb/bootstrap</additionalClasspathElement>
                                </additionalClasspathElements>
                                <forkMode>once</forkMode>
                                <jvm>${myproject.java}</jvm>
                                <argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
                    </configuration>
                 </plugin>
                <!-- ==================== -->
                </plugins>
            
              </build>
              <dependencyManagement>
                    <dependencies>
                        <dependency>
                            <groupId>javax.transaction</groupId>
                            <artifactId>jta</artifactId>
                            <version>1.0.1B</version>
                            <scope>provided</scope>
                        </dependency>
                    </dependencies>
              </dependencyManagement>
              
                  <dependencies>
                    <!-- Embedded JBoss dependencies
                         These make me a tad nervous because there are duplicate libraries on the test classpath.
                         However, Maven gives you no way to tare the classpath to zero and start fresh. -->
                    <dependency>
                           <groupId>org.jboss.seam.embedded</groupId>
                           <artifactId>jboss-embedded-all</artifactId>
                           <version>beta3.SP4</version>
                           <scope>test</scope>
                      </dependency>
                    <dependency>
                        <groupId>org.jboss.seam.embedded</groupId>
                        <artifactId>hibernate-all</artifactId>
                        <version>beta3.SP4</version>
                           <scope>test</scope>
                    </dependency>
                    <dependency> 
                           <groupId>org.jboss.seam.embedded</groupId>
                           <artifactId>thirdparty-all</artifactId> 
                           <version>beta3.SP4</version>
                           <scope>test</scope>
                      </dependency>
                    <!-- /Embedded JBoss dependencies -->
                    <dependency>
                           <groupId>javax.servlet</groupId>
                           <artifactId>servlet-api</artifactId>
                           <version>2.5</version>
                           <scope>provided</scope>
                      </dependency>
                      <dependency>
                           <groupId>javax.ejb</groupId>
                           <artifactId>ejb-api</artifactId>
                        <version>3.0</version>
                           <scope>provided</scope>
                      </dependency>
                    <dependency>
                        <groupId>javax.el</groupId>
                        <artifactId>el-api</artifactId>
                        <version>1.0</version>
                        <scope>provided</scope>
                    </dependency>
                    <dependency>
                        <groupId>org.jboss.el</groupId>
                        <artifactId>jboss-el</artifactId>
                        <version>2.0.1.GA</version>
                        <scope>provided</scope>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.facelets</groupId>
                        <artifactId>jsf-facelets</artifactId>
                        <version>1.1.14</version>
                        <scope>runtime</scope>
                    </dependency>
                    <dependency>
                        <groupId>javax.faces</groupId>
                        <artifactId>jsf-api</artifactId>
                        <version>1.2_09-BETA1</version>
                        <scope>provided</scope>
                    </dependency>
                    <dependency>
                        <groupId>javax.faces</groupId>
                        <artifactId>jsf-impl</artifactId>
                        <version>1.2_12</version>
                        <scope>provided</scope>
                    </dependency>
                    <dependency>
                        <groupId>javax.persistence</groupId>
                        <artifactId>persistence-api</artifactId>
                        <version>1.0</version>
                        <scope>provided</scope>
                    </dependency>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-validator</artifactId>
                        <version>3.0.0.GA</version>
                        <scope>compile</scope>
                    </dependency>
                    <dependency>
                           <groupId>org.jboss.seam</groupId>
                           <artifactId>jboss-seam</artifactId>
                           <version>2.1.1.GA</version>
                           <scope>provided</scope>
                      </dependency>
                    <dependency>
                        <groupId>org.jboss.seam</groupId>
                        <artifactId>jboss-seam-debug</artifactId>
                        <version>2.1.1.GA</version>
                        <scope>runtime</scope>
                    </dependency>
                    <dependency>
                        <groupId>org.testng</groupId>
                        <artifactId>testng</artifactId>
                        <version>5.6</version>
                        <scope>test</scope>
                    </dependency>
                </dependencies>
            </project>



            As you see: The jars are included. I guess that is a problem with the classpath of the surefire plugin.
            Here is the extract of the executed test:


            [DEBUG]   (f) argLine = -Dsun.lang.ClassLoader.allowArraySyntax=true
            [DEBUG]   (f) basedir = C:\Projects\My_project\main\Sourcen_maven\myproject-ejb
            [DEBUG]   (f) childDelegation = false
            [DEBUG]   (f) classesDirectory = C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\classes
            [DEBUG]   (f) classpathElements = [C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\test-classes, C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\classes, c:\Projects\javalibs\MavenRepository\junit\junit\4.0\junit-4.0.jar, c:\Projects\javalibs\MavenRepository\log4j\log4j\1.2.14\log4j-1.2.14.jar, c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-all\beta3.SP4\jboss-embedded-all-beta3.SP4.jar, c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-api\beta3.SP4\jboss-embedded-api-beta3.SP4.jar, c:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-client-spi\2.0.0.Beta6\jboss-deployers-client-spi-2.0.0.Beta6.jar, c:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-core-spi\2.0.0.Beta6\jboss-deployers-core-spi-2.0.0.Beta6.jar, c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\hibernate-all\beta3.SP4\hibernate-all-beta3.SP4.jar, c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\thirdparty-all\beta3.SP4\thirdparty-all-beta3.SP4.jar, c:\Projects\javalibs\MavenRepository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar, c:\Projects\javalibs\MavenRepository\javax\ejb\ejb-api\3.0\ejb-api-3.0.jar, c:\Projects\javalibs\MavenRepository\javax\el\el-api\1.0\el-api-1.0.jar, c:\Projects\javalibs\MavenRepository\org\jboss\el\jboss-el\2.0.1.GA\jboss-el-2.0.1.GA.jar, c:\Projects\javalibs\MavenRepository\com\sun\facelets\jsf-facelets\1.1.14\jsf-facelets-1.1.14.jar, c:\Projects\javalibs\MavenRepository\javax\faces\jsf-api\1.2_09-BETA1\jsf-api-1.2_09-BETA1.jar, c:\Projects\javalibs\MavenRepository\javax\faces\jsf-impl\1.2_12\jsf-impl-1.2_12.jar, c:\Projects\javalibs\MavenRepository\javax\persistence\persistence-api\1.0\persistence-api-1.0.jar, c:\Projects\javalibs\MavenRepository\org\hibernate\hibernate-validator\3.0.0.GA\hibernate-validator-3.0.0.GA.jar, c:\Projects\javalibs\MavenRepository\org\hibernate\hibernate\3.2.4.sp1\hibernate-3.2.4.sp1.jar, c:\Projects\javalibs\MavenRepository\net\sf\ehcache\ehcache\1.2.3\ehcache-1.2.3.jar, c:\Projects\javalibs\MavenRepository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar, c:\Projects\javalibs\MavenRepository\commons-collections\commons-collections\2.1.1\commons-collections-2.1.1.jar, c:\Projects\javalibs\MavenRepository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar, c:\Projects\javalibs\MavenRepository\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar, c:\Projects\javalibs\MavenRepository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar, c:\Projects\javalibs\MavenRepository\antlr\antlr\2.7.6\antlr-2.7.6.jar, c:\Projects\javalibs\MavenRepository\cglib\cglib\2.1_3\cglib-2.1_3.jar, c:\Projects\javalibs\MavenRepository\asm\asm\1.5.3\asm-1.5.3.jar, c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam\2.1.1.GA\jboss-seam-2.1.1.GA.jar, c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam-debug\2.1.1.GA\jboss-seam-debug-2.1.1.GA.jar, c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam\2.1.1.GA\jboss-seam-2.1.1.GA.jar, c:\Projects\javalibs\MavenRepository\org\testng\testng\5.6\testng-5.6.jar, c:\Projects\javalibs\MavenRepository\com\mypackage\library\authenticator\1.2.1\authenticator-1.2.1.jar, c:\Projects\javalibs\MavenRepository\com\mypackage\bibliothek\library\3.06-SNAPSHOT\library-3.06-SNAPSHOT.jar, c:\Projects\javalibs\MavenRepository\de\comnetmedia\evaberecht\cnm_adminservice_ws_client\1.5.0.10\cnm_adminservice_ws_client-1.5.0.10.jar, c:\Projects\javalibs\MavenRepository\com\cryptix\cryptix32\3.2.0\cryptix32-3.2.0.jar, c:\Projects\javalibs\MavenRepository\org\apache\axis\axis\1.4\axis-1.4.jar, c:\Projects\javalibs\MavenRepository\org\apache\axis\axis-jaxrpc\1.4\axis-jaxrpc-1.4.jar]
            [DEBUG]   (f) disableXmlReport = false
            [DEBUG]   (f) enableAssertions = true
            [DEBUG]   (f) forkMode = once
            [DEBUG]   (f) junitArtifactName = junit:junit
            [DEBUG]   (f) jvm = C:/Programme/Java/jdk1.6.0_11/bin/java.exe
            [DEBUG]   (f) localRepository = [local] -> file://c:/Projects/javalibs/MavenRepository
            [DEBUG]   (f) pluginArtifactMap = {org.apache.maven:maven-profile=org.apache.maven:maven-profile:jar:2.0.6:runtime, org.apache.maven:maven-toolchain=org.apache.maven:maven-toolchain:jar:1.0:runtime, org.apache.maven.wagon:wagon-ssh-external=org.apache.maven.wagon:wagon-ssh-external:jar:1.0-beta-2:runtime, org.codehaus.plexus:plexus-container-default=org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:runtime, org.apache.maven:maven-artifact-manager=org.apache.maven:maven-artifact-manager:jar:2.0.6:runtime, classworlds:classworlds=classworlds:classworlds:jar:1.1:runtime, org.apache.maven.wagon:wagon-http-lightweight=org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-beta-2:runtime, org.apache.maven:maven-monitor=org.apache.maven:maven-monitor:jar:2.0.6:runtime, org.apache.maven:maven-plugin-descriptor=org.apache.maven:maven-plugin-descriptor:jar:2.0.6:runtime, org.apache.maven.wagon:wagon-file=org.apache.maven.wagon:wagon-file:jar:1.0-beta-2:runtime, org.apache.maven.reporting:maven-reporting-api=org.apache.maven.reporting:maven-reporting-api:jar:2.0.6:runtime, org.apache.maven.doxia:doxia-sink-api=org.apache.maven.doxia:doxia-sink-api:jar:1.0-alpha-7:runtime, org.apache.maven:maven-project=org.apache.maven:maven-project:jar:2.0.6:runtime, org.apache.maven:maven-error-diagnostics=org.apache.maven:maven-error-diagnostics:jar:2.0.6:runtime, jtidy:jtidy=jtidy:jtidy:jar:4aug2000r7-dev:runtime, org.apache.maven.wagon:wagon-ssh=org.apache.maven.wagon:wagon-ssh:jar:1.0-beta-2:runtime, junit:junit=junit:junit:jar:3.8.1:runtime, org.apache.maven.wagon:wagon-http-shared=org.apache.maven.wagon:wagon-http-shared:jar:1.0-beta-2:runtime, org.apache.maven:maven-artifact=org.apache.maven:maven-artifact:jar:2.0.6:runtime, xml-apis:xml-apis=xml-apis:xml-apis:jar:1.0.b2:runtime, org.codehaus.plexus:plexus-interactivity-api=org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4:runtime, org.apache.maven.wagon:wagon-ssh-common=org.apache.maven.wagon:wagon-ssh-common:jar:1.0-beta-2:runtime, org.apache.maven:maven-model=org.apache.maven:maven-model:jar:2.0.6:runtime, org.apache.maven:maven-core=org.apache.maven:maven-core:jar:2.0.6:runtime, org.apache.maven:maven-plugin-registry=org.apache.maven:maven-plugin-registry:jar:2.0.6:runtime, org.apache.maven.surefire:surefire-booter=org.apache.maven.surefire:surefire-booter:jar:2.4.3:runtime, org.apache.maven:maven-repository-metadata=org.apache.maven:maven-repository-metadata:jar:2.0.6:runtime, org.apache.maven.wagon:wagon-provider-api=org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:runtime, org.apache.maven:maven-plugin-parameter-documenter=org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.6:runtime, org.codehaus.plexus:plexus-utils=org.codehaus.plexus:plexus-utils:jar:1.5.1:runtime, commons-cli:commons-cli=commons-cli:commons-cli:jar:1.0:runtime, org.apache.maven.surefire:surefire-api=org.apache.maven.surefire:surefire-api:jar:2.4.3:runtime, com.jcraft:jsch=com.jcraft:jsch:jar:0.1.27:runtime, org.apache.maven:maven-plugin-api=org.apache.maven:maven-plugin-api:jar:2.0.6:runtime, org.apache.maven:maven-settings=org.apache.maven:maven-settings:jar:2.0.6:runtime}
            [DEBUG]   (f) printSummary = true
            [DEBUG]   (f) project = MavenProject: com.mypackage:myproject-ejb:1.0-SNAPSHOT @ C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\pom.xml
            [DEBUG]   (f) projectArtifactMap = {org.jboss.seam.embedded:jboss-embedded-all=org.jboss.seam.embedded:jboss-embedded-all:jar:beta3.SP4:test, org.hibernate:hibernate=org.hibernate:hibernate:jar:3.2.4.sp1:compile, log4j:log4j=log4j:log4j:jar:1.2.14:compile, asm:asm-attrs=asm:asm-attrs:jar:1.5.3:compile, javax.ejb:ejb-api=javax.ejb:ejb-api:jar:3.0:provided, net.sf.ehcache:ehcache=net.sf.ehcache:ehcache:jar:1.2.3:compile, javax.faces:jsf-impl=javax.faces:jsf-impl:jar:1.2_12:provided, org.hibernate:hibernate-validator=org.hibernate:hibernate-validator:jar:3.0.0.GA:compile, com.mypackage.bibliothek:library=com.mypackage.bibliothek:library:jar:3.06-SNAPSHOT:compile, de.comnetmedia.evaberecht:cnm_adminservice_ws_client=de.comnetmedia.evaberecht:cnm_adminservice_ws_client:jar:1.5.0.10:compile, javax.faces:jsf-api=javax.faces:jsf-api:jar:1.2_09-BETA1:provided, org.jboss.seam:jboss-seam-debug=org.jboss.seam:jboss-seam-debug:jar:2.1.1.GA:runtime, org.jboss.seam.embedded:hibernate-all=org.jboss.seam.embedded:hibernate-all:jar:beta3.SP4:test, org.jboss.seam.embedded:jboss-embedded-api=org.jboss.seam.embedded:jboss-embedded-api:jar:beta3.SP4:test, org.apache.axis:axis-jaxrpc=org.apache.axis:axis-jaxrpc:jar:1.4:compile, com.cryptix:cryptix32=com.cryptix:cryptix32:jar:3.2.0:compile, org.jboss.seam:jboss-seam=org.jboss.seam:jboss-seam:ejb:2.1.1.GA:runtime, junit:junit=junit:junit:jar:4.0:test, org.testng:testng=org.testng:testng:jar:5.6:test, cglib:cglib=cglib:cglib:jar:2.1_3:compile, org.jboss.seam.embedded:thirdparty-all=org.jboss.seam.embedded:thirdparty-all:jar:beta3.SP4:test, asm:asm=asm:asm:jar:1.5.3:compile, org.apache.axis:axis=org.apache.axis:axis:jar:1.4:compile, dom4j:dom4j=dom4j:dom4j:jar:1.6.1:compile, org.jboss.microcontainer:jboss-deployers-client-spi=org.jboss.microcontainer:jboss-deployers-client-spi:jar:2.0.0.Beta6:test, org.jboss.microcontainer:jboss-deployers-core-spi=org.jboss.microcontainer:jboss-deployers-core-spi:jar:2.0.0.Beta6:test, com.mypackage.library:authenticator=com.mypackage.library:authenticator:jar:1.2.1:compile, javax.servlet:servlet-api=javax.servlet:servlet-api:jar:2.5:provided, javax.persistence:persistence-api=javax.persistence:persistence-api:jar:1.0:provided, commons-collections:commons-collections=commons-collections:commons-collections:jar:2.1.1:compile, javax.transaction:jta=javax.transaction:jta:jar:1.0.1B:provided, com.sun.facelets:jsf-facelets=com.sun.facelets:jsf-facelets:jar:1.1.14:runtime, commons-logging:commons-logging=commons-logging:commons-logging:jar:1.0.4:compile, org.jboss.el:jboss-el=org.jboss.el:jboss-el:jar:2.0.1.GA:provided, antlr:antlr=antlr:antlr:jar:2.7.6:compile, javax.el:el-api=javax.el:el-api:jar:1.0:provided}
            [DEBUG]   (f) redirectTestOutputToFile = false
            [DEBUG]   (f) remoteRepositories = [[IHK-GfI] -> ${corporate-pom.scm.url}/content/groups/public, [central] -> http://repo1.maven.org/maven2]
            [DEBUG]   (f) reportFormat = brief
            [DEBUG]   (f) reportsDirectory = C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\surefire-reports
            [DEBUG]   (f) session = org.apache.maven.execution.MavenSession@157c2bd
            [DEBUG]   (f) testClassesDirectory = C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\test-classes
            [DEBUG]   (f) testNGArtifactName = org.testng:testng
            [DEBUG]   (f) testSourceDirectory = C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\src\test\java
            [DEBUG]   (f) trimStackTrace = true
            [DEBUG]   (f) useFile = true
            [DEBUG]   (f) useManifestOnlyJar = false
            [DEBUG]   (f) workingDirectory = C:\Projects\My_project\main\Sourcen_maven\myproject-ejb
            [DEBUG] -- end configuration --
            [INFO] [surefire:test]
            [DEBUG] Setting context classloader for plugin to: /plugins/org.apache.maven.plugins:maven-surefire-plugin:2.4.3@48/thread:main (instance is: ClassRealm[/plugins/org.apache.maven.plugins:maven-surefire-plugin:2.4.3@48/thread:main, parent: ClassRealm[plexus.core, parent: null]])
            [DEBUG] dummy:dummy:jar:1.0 (selected for null)
            [DEBUG]   org.apache.maven.surefire:surefire-booter:jar:2.4.3:runtime (selected for runtime)
            [DEBUG]     org.apache.maven.surefire:surefire-api:jar:2.4.3:runtime (selected for runtime)
            [DEBUG] Adding to surefire booter test classpath: c:\Projects\javalibs\MavenRepository\org\apache\maven\surefire\surefire-booter\2.4.3\surefire-booter-2.4.3.jar
            [DEBUG] Adding to surefire booter test classpath: c:\Projects\javalibs\MavenRepository\org\apache\maven\surefire\surefire-api\2.4.3\surefire-api-2.4.3.jar
            [DEBUG] dummy:dummy:jar:1.0 (selected for null)
            [DEBUG]   org.testng:testng:jar:5.6:test (selected for test)
            [DEBUG]     junit:junit:jar:3.8.1:test (selected for test)
            [DEBUG] Adding to surefire booter test classpath: c:\Projects\javalibs\MavenRepository\org\testng\testng\5.6\testng-5.6.jar
            [DEBUG] Adding to surefire booter test classpath: c:\Projects\javalibs\MavenRepository\junit\junit\3.8.1\junit-3.8.1.jar
            [DEBUG] dummy:dummy:jar:1.0 (selected for null)
            [DEBUG] Adding managed dependencies for unknown:surefire-testng
            [DEBUG]   org.apache.maven.surefire:surefire-api:jar:2.4.3
            [DEBUG]   org.apache.maven.surefire:surefire-booter:jar:2.4.3
            [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.5.1
            [DEBUG]   org.apache.maven.surefire:surefire-testng:jar:2.4.3:test (selected for test)
            [DEBUG]     junit:junit:jar:3.8.1:test (selected for test)
            [DEBUG]     org.apache.maven.surefire:surefire-api:jar:2.4.3:test (selected for test)
            [DEBUG]     org.apache.maven:maven-artifact:jar:2.0:test (selected for test)
            [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:test (selected for test)
            [DEBUG]     org.testng:testng:jar:jdk15:5.7:test (selected for test)
            [DEBUG] Adding to surefire test classpath: c:\Projects\javalibs\MavenRepository\org\apache\maven\surefire\surefire-testng\2.4.3\surefire-testng-2.4.3.jar
            [DEBUG] Adding to surefire test classpath: c:\Projects\javalibs\MavenRepository\junit\junit\3.8.1\junit-3.8.1.jar
            [DEBUG] Adding to surefire test classpath: c:\Projects\javalibs\MavenRepository\org\apache\maven\surefire\surefire-api\2.4.3\surefire-api-2.4.3.jar
            [DEBUG] Adding to surefire test classpath: c:\Projects\javalibs\MavenRepository\org\apache\maven\maven-artifact\2.0\maven-artifact-2.0.jar
            [DEBUG] Adding to surefire test classpath: c:\Projects\javalibs\MavenRepository\org\codehaus\plexus\plexus-utils\1.0.4\plexus-utils-1.0.4.jar
            [DEBUG] Test Classpath :
            [DEBUG]   C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\test-classes
            [DEBUG]   C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\classes
            [DEBUG]   c:\Projects\javalibs\MavenRepository\junit\junit\4.0\junit-4.0.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\log4j\log4j\1.2.14\log4j-1.2.14.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-all\beta3.SP4\jboss-embedded-all-beta3.SP4.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-api\beta3.SP4\jboss-embedded-api-beta3.SP4.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-client-spi\2.0.0.Beta6\jboss-deployers-client-spi-2.0.0.Beta6.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-core-spi\2.0.0.Beta6\jboss-deployers-core-spi-2.0.0.Beta6.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\hibernate-all\beta3.SP4\hibernate-all-beta3.SP4.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\thirdparty-all\beta3.SP4\thirdparty-all-beta3.SP4.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\ejb\ejb-api\3.0\ejb-api-3.0.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\el\el-api\1.0\el-api-1.0.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\el\jboss-el\2.0.1.GA\jboss-el-2.0.1.GA.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\com\sun\facelets\jsf-facelets\1.1.14\jsf-facelets-1.1.14.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\faces\jsf-api\1.2_09-BETA1\jsf-api-1.2_09-BETA1.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\faces\jsf-impl\1.2_12\jsf-impl-1.2_12.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\persistence\persistence-api\1.0\persistence-api-1.0.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\hibernate\hibernate-validator\3.0.0.GA\hibernate-validator-3.0.0.GA.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\hibernate\hibernate\3.2.4.sp1\hibernate-3.2.4.sp1.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\net\sf\ehcache\ehcache\1.2.3\ehcache-1.2.3.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\commons-collections\commons-collections\2.1.1\commons-collections-2.1.1.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\antlr\antlr\2.7.6\antlr-2.7.6.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\cglib\cglib\2.1_3\cglib-2.1_3.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\asm\asm\1.5.3\asm-1.5.3.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam\2.1.1.GA\jboss-seam-2.1.1.GA.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam-debug\2.1.1.GA\jboss-seam-debug-2.1.1.GA.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam\2.1.1.GA\jboss-seam-2.1.1.GA.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\testng\testng\5.6\testng-5.6.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\apache\axis\axis\1.4\axis-1.4.jar
            [DEBUG]   c:\Projects\javalibs\MavenRepository\org\apache\axis\axis-jaxrpc\1.4\axis-jaxrpc-1.4.jar
            [DEBUG]   C:/Projects/My_project/main/Sourcen_maven/myproject-ejb/bootstrap
            [DEBUG] Setting system property [user.dir]=[C:\Projects\My_project\main\Sourcen_maven\myproject-ejb]
            [DEBUG] Setting system property [localRepository]=[c:/Projects/javalibs/MavenRepository]
            [DEBUG] Setting system property [basedir]=[C:\Projects\My_project\main\Sourcen_maven\myproject-ejb]
            [INFO] Surefire report directory: C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\surefire-reports
            Forking command line: cmd.exe /X /C "C:\Programme\Java\jdk1.6.0_11\bin\java.exe -Dsun.lang.ClassLoader.allowArraySyntax=true -classpath c:\Projects\javalibs\MavenRepository\org\apache\maven\surefire\surefire-booter\2.4.3\surefire-booter-2.4.3.jar;c:\Projects\javalibs\MavenRepository\org\apache\maven\surefire\surefire-api\2.4.3\surefire-api-2.4.3.jar;c:\Projects\javalibs\MavenRepository\org\testng\testng\5.6\testng-5.6.jar;c:\Projects\javalibs\MavenRepository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\test-classes;C:\Projects\My_project\main\Sourcen_maven\myproject-ejb\target\classes;c:\Projects\javalibs\MavenRepository\junit\junit\4.0\junit-4.0.jar;c:\Projects\javalibs\MavenRepository\log4j\log4j\1.2.14\log4j-1.2.14.jar;c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-all\beta3.SP4\jboss-embedded-all-beta3.SP4.jar;c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-api\beta3.SP4\jboss-embedded-api-beta3.SP4.jar;c:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-client-spi\2.0.0.Beta6\jboss-deployers-client-spi-2.0.0.Beta6.jar;c:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-core-spi\2.0.0.Beta6\jboss-deployers-core-spi-2.0.0.Beta6.jar;c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\hibernate-all\beta3.SP4\hibernate-all-beta3.SP4.jar;c:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\thirdparty-all\beta3.SP4\thirdparty-all-beta3.SP4.jar;c:\Projects\javalibs\MavenRepository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar;c:\Projects\javalibs\MavenRepository\javax\ejb\ejb-api\3.0\ejb-api-3.0.jar;c:\Projects\javalibs\MavenRepository\javax\el\el-api\1.0\el-api-1.0.jar;c:\Projects\javalibs\MavenRepository\org\jboss\el\jboss-el\2.0.1.GA\jboss-el-2.0.1.GA.jar;c:\Projects\javalibs\MavenRepository\com\sun\facelets\jsf-facelets\1.1.14\jsf-facelets-1.1.14.jar;c:\Projects\javalibs\MavenRepository\javax\faces\jsf-api\1.2_09-BETA1\jsf-api-1.2_09-BETA1.jar;c:\Projects\javalibs\MavenRepository\javax\faces\jsf-impl\1.2_12\jsf-impl-1.2_12.jar;c:\Projects\javalibs\MavenRepository\javax\persistence\persistence-api\1.0\persistence-api-1.0.jar;c:\Projects\javalibs\MavenRepository\org\hibernate\hibernate-validator\3.0.0.GA\hibernate-validator-3.0.0.GA.jar;c:\Projects\javalibs\MavenRepository\org\hibernate\hibernate\3.2.4.sp1\hibernate-3.2.4.sp1.jar;c:\Projects\javalibs\MavenRepository\net\sf\ehcache\ehcache\1.2.3\ehcache-1.2.3.jar;c:\Projects\javalibs\MavenRepository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar;c:\Projects\javalibs\MavenRepository\commons-collections\commons-collections\2.1.1\commons-collections-2.1.1.jar;c:\Projects\javalibs\MavenRepository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar;c:\Projects\javalibs\MavenRepository\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar;c:\Projects\javalibs\MavenRepository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;c:\Projects\javalibs\MavenRepository\antlr\antlr\2.7.6\antlr-2.7.6.jar;c:\Projects\javalibs\MavenRepository\cglib\cglib\2.1_3\cglib-2.1_3.jar;c:\Projects\javalibs\MavenRepository\asm\asm\1.5.3\asm-1.5.3.jar;c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam\2.1.1.GA\jboss-seam-2.1.1.GA.jar;c:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam-debug\2.1.1.GA\jboss-seam-debug-2.1.1.GA.jar;c:\Projects\javalibs\MavenRepository\org\testng\testng\5.6\testng-5.6.jar;c:\Projects\javalibs\MavenRepository\org\apache\axis\axis\1.4\axis-1.4.jar;c:\Projects\javalibs\MavenRepository\org\apache\axis\axis-jaxrpc\1.4\axis-jaxrpc-1.4.jar;C:/Projects/My_project/main/Sourcen_maven/myproject-ejb/bootstrap org.apache.maven.surefire.booter.SurefireBooter C:\DOKUME~1\myproject\LOKALE~1\Temp\surefire36202tmp C:\DOKUME~1\myproject\LOKALE~1\Temp\surefire36203tmp"



            Is there a difference between the test classpath and the surefire test classpath?
            If there is a difference: Why the embedded-libs are not loaded in surefire test classpath? I don't know where is the problem. In my opinion the libs are listed in the pom.xml correctly.


            Can you give me another hint? That's a really tough problem.

            • 3. Re: TestNG & Maven: How to configure it correctly

              According to this link there is a problem with the order of the classpath:http://mail-archives.apache.org/mod_mbox/maven-users/200807.mbox/%3COF92D3F344.80C97141-ONC1257489.002EA239-C1257489.002F4A5B@gi-de.com%3E
              The libs are listed in the correct order, but the classpath is not build up correctly.


              Do you know what could be the problem?

              • 4. Re: TestNG & Maven: How to configure it correctly

                Furthermore I've tried the following configuration without any sucess (the same error occurs):



                <plugin>
                      <artifactId>maven-antrun-plugin</artifactId>
                      <executions>
                
                        <!-- this ant script runs testng natively -->
                        <execution>
                          <id>testng</id>
                          <phase>test</phase>
                          <configuration>
                            <tasks>
                            
                               <taskdef resource="testngtasks" classpath="testng.jar"
                                       classpathref="maven.test.classpath"/>
                              <testng classpathref="maven.test.classpath"
                                      outputdir="target/test-reports">
                                <xmlfileset dir="src/test/suites" includes="*.xml"/>
                              </testng>
                              <junitreport todir="target/test-reports">
                                <fileset dir="target/test-reports">
                                  <include name="**/*.xml" />
                                </fileset>
                                <report format="noframes" todir="target/test-reports" />
                              </junitreport>
                            </tasks>
                          </configuration>
                          <goals><goal>run</goal></goals>
                        </execution>
                      </executions>
                      <dependencies>
                        <dependency>
                          <groupId>ant</groupId>
                          <artifactId>ant-junit</artifactId>
                          <version>1.6.2</version>
                        </dependency>
                      </dependencies>
                    </plugin>
                
                    <!-- disable surefire plugin (too many problems!) -->
                    <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <configuration>
                        <skip>true</skip>
                      </configuration>
                    </plugin>
                    <!-- ==================== -->
                    </plugins>



                This is the maven.test.classpath:


                C:\Projects\My_Project\main\Sourcen_maven\myproject-ejb\target\test-classes
                C:\Projects\My_Project\main\Sourcen_maven\myproject-ejb\target\classes
                C:\Projects\javalibs\MavenRepository\junit\junit\4.0\junit-4.0.jar
                C:\Projects\javalibs\MavenRepository\log4j\log4j\1.2.14\log4j-1.2.14.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-all\beta3.SP4\jboss-embedded-all-beta3.SP4.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\jboss-embedded-api\beta3.SP4\jboss-embedded-api-beta3.SP4.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-client-spi\2.0.0.Beta6\jboss-deployers-client-spi-2.0.0.Beta6.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\microcontainer\jboss-deployers-core-spi\2.0.0.Beta6\jboss-deployers-core-spi-2.0.0.Beta6.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\hibernate-all\beta3.SP4\hibernate-all-beta3.SP4.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\seam\embedded\thirdparty-all\beta3.SP4\thirdparty-all-beta3.SP4.jar
                C:\Projects\javalibs\MavenRepository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar
                C:\Projects\javalibs\MavenRepository\javax\ejb\ejb-api\3.0\ejb-api-3.0.jar
                C:\Projects\javalibs\MavenRepository\javax\el\el-api\1.0\el-api-1.0.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\el\jboss-el\2.0.1.GA\jboss-el-2.0.1.GA.jar
                C:\Projects\javalibs\MavenRepository\com\sun\facelets\jsf-facelets\1.1.14\jsf-facelets-1.1.14.jar
                C:\Projects\javalibs\MavenRepository\javax\faces\jsf-api\1.2_09-BETA1\jsf-api-1.2_09-BETA1.jar
                C:\Projects\javalibs\MavenRepository\javax\faces\jsf-impl\1.2_12\jsf-impl-1.2_12.jar
                C:\Projects\javalibs\MavenRepository\javax\persistence\persistence-api\1.0\persistence-api-1.0.jar
                C:\Projects\javalibs\MavenRepository\org\hibernate\hibernate-validator\3.0.0.GA\hibernate-validator-3.0.0.GA.jar
                C:\Projects\javalibs\MavenRepository\org\hibernate\hibernate\3.2.4.sp1\hibernate-3.2.4.sp1.jar
                C:\Projects\javalibs\MavenRepository\net\sf\ehcache\ehcache\1.2.3\ehcache-1.2.3.jar
                C:\Projects\javalibs\MavenRepository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar
                C:\Projects\javalibs\MavenRepository\commons-collections\commons-collections\2.1.1\commons-collections-2.1.1.jar
                C:\Projects\javalibs\MavenRepository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar
                C:\Projects\javalibs\MavenRepository\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar
                C:\Projects\javalibs\MavenRepository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar
                C:\Projects\javalibs\MavenRepository\antlr\antlr\2.7.6\antlr-2.7.6.jar
                C:\Projects\javalibs\MavenRepository\cglib\cglib\2.1_3\cglib-2.1_3.jar
                C:\Projects\javalibs\MavenRepository\asm\asm\1.5.3\asm-1.5.3.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam\2.1.1.GA\jboss-seam-2.1.1.GA.jar
                C:\Projects\javalibs\MavenRepository\org\jboss\seam\jboss-seam-debug\2.1.1.GA\jboss-seam-debug-2.1.1.GA.jar
                C:\Projects\javalibs\MavenRepository\org\testng\testng\5.6\testng-5.6.jar
                C:\Projects\javalibs\MavenRepository\com\cryptix\cryptix32\3.2.0\cryptix32-3.2.0.jar
                C:\Projects\javalibs\MavenRepository\org\apache\axis\axis\1.4\axis-1.4.jar
                C:\Projects\javalibs\MavenRepository\org\apache\axis\axis-jaxrpc\1.4\axis-jaxrpc-1.4.jar


                • 5. Re: TestNG & Maven: How to configure it correctly
                  dan.j.allen

                  If you can't get it to run with the antrun plugin, then you likely have other problems. There are a lot of factors that can cause the tests to fail. It's important to work from a known state (an example) and add complexity until you figure out what is causing the problem. You are never going to get there if you keep changing things around in the broken state.


                  You are certainly better off now with your configuration. But here's where your problem is:


                  UNRESOLVED Demands 'jboss.jca:name=jdbc/myproj,service=DataSourceBinding



                  You aren't using the data source you think you are using (java:/DefaultDS). Where is jdbc/myproj defined? When you answer that question (and why it is being requested) you may have success.

                  • 6. Re: TestNG & Maven: How to configure it correctly

                    Thanks Dan for your answer.


                    But this is exactly the point which I don't understand:


                    In my opinion it is a question of configuration, because if you are executing the test with the TestNG plugin of Eclipse it's working fine.


                    Therefore I come the conclusion it must be something with the configuration of my pom.xml.
                    Do you agree with me, or I am on the wrong track?


                    As I mentioned in the first post I have already tried to split the problem in several sections. The generated Seamproject is running perfectly with Ant.


                    But the application of the generated Seamproject to Maven is the real tricky part.


                    To illustrate the problem better here is the structure of the project:



                    MyProjEJB
                    ->bootstrap
                    ->lib (libs of the generated SeamGen-project)
                    ->src
                               ->main
                                     ->java(Beans and interfaces inside) 
                                     ->resources
                                                 ->META-INF
                                                           ->ejb-jar.xml
                                                           ->persistence.xml(for the application -> jdbc/myproj is defined there)
                               ->test
                               ->java
                                     ->MyTest.java
                               ->resources
                                         ->META-INF
                                                           ->persistence.properties
                                                           ->persistence-test.xml(for the test -> java:/DefaultDS is defined there)
                    ->target
                               ->classes
                               ->surefire-reports
                               ->test-classes
                    ->pom.xml



                    Regards

                    • 7. Re: TestNG & Maven: How to configure it correctly
                      dan.j.allen
                      But this is exactly the point which I don't understand:

                      In my opinion it is a question of configuration, because if you are executing the test with the TestNG plugin of Eclipse it's working fine.


                      Your statement is exactly the truth I am calling into question. You are assuming that the classpath that Eclipse sees is the very same classpath as what Maven sees. I believe that they are, in fact, different. Eclipse crams everything into the same classpath, often overwriting configuration files that come from different source paths. It could be that when Eclipse runs, it is clobbering the persistence.xml that Maven uses and is instead using one from somewhere else (or vice versa).


                      Whenever you have a question about classpath entries, I always find it useful to change something so dramatically in the file that it would be clearly obviously that the file I think is being used is in fact not being used.


                      Sorry that I'm giving more advice than just specifics, but these things really are tough to debug without being able to get in there and move things around...at least for me.

                      • 8. Re: TestNG & Maven: How to configure it correctly

                        First of all: Thanks for your patience. I know, that these things are tough to debug without being able to get in there.


                        I have found out, that before the test starts the ejb-components will be created first.
                        Therefore I deleted the persistence.xml of the ejbs and removed the annotations of the EntityManagers to just test the execution of a real simply test by Maven.


                        Now this error occurs:


                        java.lang.RuntimeException: Could not create Component: myService
                             at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1178)
                             at org.jboss.seam.init.Initialization.installComponents(Initialization.java:1094)
                             at org.jboss.seam.init.Initialization.init(Initialization.java:728)
                             at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:919)
                             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:604)
                             at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:394)
                             at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
                             at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:79)
                             at org.testng.SuiteRunner.privateRun(SuiteRunner.java:261)
                             at org.testng.SuiteRunner.run(SuiteRunner.java:190)
                             at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
                             at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
                             at org.testng.TestNG.run(TestNG.java:699)
                             at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62)
                             at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141)
                             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:345)
                             at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
                        Caused by: java.lang.IllegalArgumentException: You must specify org.jboss.seam.core.init.jndiPattern or use @JndiName: myService
                             at org.jboss.seam.Component.getJndiName(Component.java:448)
                             at org.jboss.seam.Component.&lt;init&gt;(Component.java:234)
                             at org.jboss.seam.Component.&lt;init&gt;(Component.java:206)
                             at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1162)
                             ... 26 more




                        That makes sense to me. But what could be a workaround? Currently I have two different persistence.xmls, because of two different databases:
                        One the one side a

                        transaction-type="RESOURCE_LOCAL"

                        for the embedded JBoss and one the other side a default transaction type for the application.


                        What could be the best practice?


                        Thanks for your patience once again, Dan.

                        • 9. Re: TestNG & Maven: How to configure it correctly
                          dan.j.allen

                          Now your problem seems much simpler. You just need to make sure that the <core:init> component has a JNDI pattern specified so that Seam can link up with EJBs. For Embedded JBoss, that pattern is:


                          <core:init jndiPattern="#{ejbName}/local"/>



                          Note that the pattern is not an EL expression, even though it appears like one.


                          If you have two different databases, you can still define them in the same persistence.xml using two <persistence-unit> elements.

                          • 10. Re: TestNG & Maven: How to configure it correctly

                            In the components.xml of the MYPROJ-WAR-project there is already an entry like that (configured for Glassfish):



                            <core:init jndi-pattern="java:comp/env/myproj-ear/#{ejbName}/local" debug="true"/>



                            Or have the the JNDI pattern to be defined in the Embedded JBoss? If yes: In which file?

                            • 11. Re: TestNG & Maven: How to configure it correctly
                              dan.j.allen

                              Well, if you are using Maven 2, then it needs to be src/test/resources/META-INF/components.xml. You will need to get Eclipse to use this file when you run tests. That is where using Eclipse gets tricky. JBossTools solves this problem by putting tests in a separate Eclipse project, hence a separate classpath. You can do that with Maven as well. Just make two Maven projects.

                              • 12. Re: TestNG & Maven: How to configure it correctly
                                dan.j.allen

                                And yes, you have to use <core:init jndiPattern="#{ejbName}/local"/> for JBoss Embedded.

                                • 13. Re: TestNG & Maven: How to configure it correctly
                                  troy.sellers

                                  Hi All,


                                  I found this http://jira.codehaus.org/browse/SUREFIRE-443 that describes the problem I was seeing and a pretty ugly kinda fix. The main problem I have found with this approach (it does work) is that the Windows Indexing service (part of xp sp3) will lock the directory that this script creates and needs some kind of unlocking tool to delete it.  (If you are lucky enough not to be humped with a windoze work environment u might miss this)


                                  This is still listed as an open issue with the surefire people...


                                  Dan, thanks for the book, the golfing metaphors worked :-)


                                  Cheers,
                                  Troy

                                  • 14. Re: TestNG & Maven: How to configure it correctly
                                    dan.j.allen

                                    I found this http://jira.codehaus.org/browse/SUREFIRE-443 that describes the problem I was seeing and a pretty ugly kinda fix. The main problem I have found with this approach (it does work) is that the Windows Indexing service (part of xp sp3) will lock the directory that this script creates and needs some kind of unlocking tool to delete it.  (If you are lucky enough not to be humped with a windoze work environment u might miss this)


                                    Now I get it, that makes sense. I never thought about the double classpath problem.



                                    This is still listed as an open issue with the surefire people...


                                    Typical response from the Maven 2 guys. It isn't a perfect scenario, so Maven 2 can't accommodate it. That explains my grudge against the tool.



                                    Dan, thanks for the book, the golfing metaphors worked :-)


                                    Haha, thanks! I'm glad to hear that. I'm hoping the book helps folks like you get to a working app sooner so that you can enjoy a lazy afternoon on the couch actually watching golf ;)


                                    1 2 Previous Next