1 Reply Latest reply on Nov 25, 2008 4:33 AM by Troy Sellers

    Error running testng

    Troy Sellers Newbie

      Hi All,


      I am getting an error running my tests


      org.jboss.seam.InstantiationException: Could not instantiate Seam component: MatadorLiteEntityManagerFactory
           at org.jboss.seam.Component.newInstance(Component.java:2096)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:112)
           at org.jboss.seam.init.Initialization.init(Initialization.java:727)
           at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:920)
           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:585)
           at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
           at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:398)
           at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
           at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:82)
           at org.testng.SuiteRunner.privateRun(SuiteRunner.java:278)
           at org.testng.SuiteRunner.run(SuiteRunner.java:198)
           at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:821)
           at org.testng.TestNG.runSuitesLocally(TestNG.java:788)
           at org.testng.TestNG.run(TestNG.java:708)
           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:585)
           at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
           at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
      Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named MatadorLite
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
           at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:85)
           at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50)
           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:585)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2209)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2124)
           at org.jboss.seam.Component.newInstance(Component.java:2084)
           ... 28 more



      I am running maven2 build and have configured my src/test/resources


      META-INF
         - components.xml
         - persistence.xml
      components.properties
      seam.properties





      I thought the No Persistence provider error was because the peristence.xml couldn't be found on the classpath, yet the components.xml can be found here?
      Anyone have a suggestion on what I am missing here?


      I have included a test datasource in the bootstrap/deploy directory using hsql.
      Cheers,
      Troy

        • 1. Re: Error running testng
          Troy Sellers Newbie

          Hi All,


          Seam 2.1 maven integration with testing.
          We used a single pom that built to a war file. 


          Well, problem turned out to be configuration (surprise!!).


          So, here is what I did, no guarantees this is the RIGHT way to do this :-).


          Copied the bootstrap created by seam-gen into my project (wanted everything in one project).
          Created persistence.xml in the src/test/resources/META-INF
          The transaction-type is RESOURCE LOCAL for the testing PU
          Added seam.properties and component.properties in src/test/resources



          Used this pom.xml


          <?xml version="1.0" encoding="UTF-8"?>
          
          <project>
               <modelVersion>4.0.0</modelVersion>
               <groupId>org.project.something</groupId>
               <artifactId>someArtifact</artifactId>
               <packaging>war</packaging>
               <version>1.0-SNAPSHOT</version>
               <name>Some Artifact</name>
          
          
               <build>
                    <plugins>
                         <plugin>
                              <artifactId>maven-compiler-plugin</artifactId>
                              <inherited>true</inherited>
                              <configuration>
                                   <source>1.5</source>
                                   <target>1.5</target>
                              </configuration>
                         </plugin>
                         <plugin>
                              <groupId>org.apache.maven.plugins</groupId>
                              <artifactId>maven-war-plugin</artifactId>
                              <version>2.0</version>
                         </plugin>
                         <plugin>
                              <groupId>org.apache.maven.plugins</groupId>
                              <artifactId>maven-surefire-plugin</artifactId>
                              <version>2.4.2</version>
                         </plugin>                
                      <plugin>
                          <groupId>org.codehaus.mojo</groupId>
                          <artifactId>surefire-report-maven-plugin</artifactId>
                      </plugin>
                         <plugin>
                              <groupId>org.apache.maven.plugins</groupId>
                              <artifactId>maven-surefire-plugin</artifactId>
                              <configuration>
                              <additionalClasspathElements>
                                  <additionalClasspathElement>bootstrap</additionalClasspathElement>
                                  <additionalClasspathElement>src/main/webapp</additionalClasspathElement>
                              </additionalClasspathElements>
                              <childDelegation>true</childDelegation>
                              <useSystemClassLoader>true</useSystemClassLoader>
                          </configuration>
                         </plugin>            
                    </plugins>
               </build>
               
               <prerequisites>
                    <maven>2.0.9</maven>
               </prerequisites>
          
               <properties>
                    <seam.version>2.1.0.SP1</seam.version>
                    <iceFaces.version>1.7.2</iceFaces.version>
               </properties>
               
               <dependencies>
                    <dependency>
                         <groupId>org.jboss.seam</groupId>
                         <artifactId>jboss-seam</artifactId>
                         <version>${seam.version}</version>
                         <exclusions>
                              <exclusion>
                                   <groupId>javax.el</groupId>
                                   <artifactId>el-api</artifactId>
                              </exclusion>
                              <exclusion>
                                   <groupId>javax.servlet</groupId>
                                   <artifactId>servlet-api</artifactId>
                              </exclusion>
                              <exclusion>
                                   <groupId>jboss</groupId>
                                   <artifactId>javassist</artifactId>
                              </exclusion>
                         </exclusions>
                    </dependency>
                    <dependency>
                         <groupId>org.jboss.seam</groupId>
                         <artifactId>jboss-seam-ui</artifactId>
                         <version>${seam.version}</version>
                         <exclusions>
                              <exclusion>
                                   <groupId>javax.servlet</groupId>
                                   <artifactId>servlet-api</artifactId>
                              </exclusion>
                              <exclusion>
                                   <groupId>javax.el</groupId>
                                   <artifactId>el-api</artifactId>
                              </exclusion>                    
                         </exclusions>
                    </dependency>
                    <dependency>
                         <groupId>org.jboss.seam</groupId>
                         <artifactId>jboss-seam-ioc</artifactId>
                         <version>${seam.version}</version>
                         <exclusions>
                              <exclusion>
                                   <groupId>javax.servlet</groupId>
                                   <artifactId>servlet-api</artifactId>
                              </exclusion>
                              <exclusion>
                                   <groupId>javax.el</groupId>
                                   <artifactId>el-api</artifactId>
                              </exclusion>                         
                         </exclusions>
                    </dependency>
                    <dependency>
                         <groupId>org.jboss.seam</groupId>
                         <artifactId>jboss-seam-debug</artifactId>
                         <version>${seam.version}</version>
                         <exclusions>
                              <exclusion>
                                   <groupId>javax.servlet</groupId>
                                   <artifactId>servlet-api</artifactId>
                              </exclusion>
                              <exclusion>
                                   <groupId>javax.el</groupId>
                                   <artifactId>el-api</artifactId>
                              </exclusion>                         
                         </exclusions>
                    </dependency>
                    <dependency>
                         <groupId>org.hibernate</groupId>
                         <artifactId>hibernate-validator</artifactId>
                         <version>3.0.0.GA</version>
                         <scope>provided</scope>
                    </dependency>
                    <dependency>
                         <groupId>javax.persistence</groupId>
                         <artifactId>persistence-api</artifactId>
                         <scope>provided</scope>
                         <version>1.0</version>
                    </dependency>
                    <dependency>
                         <groupId>javax.servlet</groupId>
                         <artifactId>servlet-api</artifactId>
                         <version>2.5</version>
                         <scope>provided</scope>
                    </dependency>
                    <dependency>
                         <groupId>javax.faces</groupId>
                         <artifactId>jsf-api</artifactId>
                         <version>1.2_08</version>
                         <scope>provided</scope>
                    </dependency>
                    <dependency>
                         <groupId>org.icefaces</groupId>
                         <artifactId>icefaces</artifactId>
                         <version>${iceFaces.version}</version>
                         <exclusions>
                              <exclusion>
                                   <groupId>javax.el</groupId>
                                   <artifactId>el-api</artifactId>
                              </exclusion>
                         </exclusions>               
                    </dependency>
                    <dependency>
                         <groupId>org.icefaces</groupId>
                         <artifactId>icefaces-comps</artifactId>
                         <version>${iceFaces.version}</version>
                    </dependency>
                    <dependency>
                         <groupId>org.icefaces</groupId>
                         <artifactId>icefaces-facelets</artifactId>
                         <version>${iceFaces.version}</version>
                         <exclusions>
                              <exclusion>
                                   <groupId>javax.el</groupId>
                                   <artifactId>el-api</artifactId>
                              </exclusion>
                         </exclusions>                    
                    </dependency>
                    <dependency>
                         <groupId>net.sourceforge.jtds</groupId>
                         <artifactId>jtds</artifactId>
                         <version>1.2.2</version>
                         <scope>provided</scope>
                    </dependency>
                    <dependency>
                         <groupId>org.jboss.el</groupId>
                         <artifactId>jboss-el</artifactId>
                         <version>2.0.2.CR1</version>
                         <exclusions>
                              <exclusion>
                                   <groupId>javax.el</groupId>
                                   <artifactId>el-api</artifactId>
                              </exclusion>
                         </exclusions>               
                    </dependency>
                      <dependency>
                          <groupId>javax.ejb</groupId>
                           <artifactId>ejb-api</artifactId>
                           <version>3.0</version>
                        <scope>provided</scope>
                      </dependency>      
                      
                      <!-- ####################################################### -->
                      <!-- Test Scoped dependencies                                         -->
                      <!-- Runs integration tests using SeamTest and JBoss           -->
                      <!-- Embedded framework                                                   -->
                      <!-- ####################################################### -->     
                       <dependency>
                            <groupId>org.testng</groupId>
                            <artifactId>testng</artifactId>
                            <version>5.8</version>
                            <scope>test</scope>
                             <classifier>jdk15</classifier>
                      </dependency>
                    <dependency>
                         <groupId>org.eclipse.jdt</groupId>
                         <artifactId>core</artifactId>
                         <version>3.2.0.658</version>
                         <scope>test</scope>
                    </dependency> 
                    <dependency>
                         <groupId>org.jboss.embedded</groupId>
                         <artifactId>hibernate-all</artifactId>
                         <version>beta3.SP3</version>
                         <scope>test</scope>
                    </dependency>
                    <dependency>
                         <groupId>org.jboss.embedded</groupId>
                         <artifactId>jboss-embedded-all</artifactId>
                         <version>beta3.SP3</version>
                         <scope>test</scope>
                    </dependency>          
                    <dependency>
                         <groupId>org.jboss.embedded</groupId>
                         <artifactId>jboss-embedded-api</artifactId>
                         <version>beta2</version>
                         <scope>test</scope>
                    </dependency>               
                    <dependency>
                         <groupId>org.jboss.embedded</groupId>
                         <artifactId>thirdparty-all</artifactId>
                         <version>beta3.SP2</version>
                         <scope>test</scope>
                    </dependency>          
                    <dependency>
                         <groupId>org.jboss.el</groupId>
                         <artifactId>jboss-el</artifactId>
                         <version>2.0.2.CR1</version>
                         <scope>test</scope>
                    </dependency>               
                    <dependency>
                         <groupId>javax.faces</groupId>
                        <artifactId>jsf-api</artifactId>
                        <version>1.2_02</version>
                         <scope>test</scope>
                    </dependency>      
                    <dependency>
                        <groupId>javax.activation</groupId>
                        <artifactId>activation</artifactId>
                        <version>1.1</version>
                        <scope>test</scope>
                    </dependency> 
               </dependencies>                
          </project>



          Cheers,
          Troy