2014-06-04 4 views
6

Ich habe diese pom.xml Dateikann nicht neue Instanz der Klasse erstellen org.jboss.arquillian.test.impl.EventTestRunnerAdaptor

<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/xsd/maven-4.0.0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 

    <parent> 
     <groupId>company</groupId> 
     <artifactId>trick-services-parent</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
    </parent> 

    <artifactId>tricker-services-webapp</artifactId> 
    <packaging>war</packaging> 
    <name>trick-rest</name> 
    <!-- <build> <finalName>trick</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> <configuration> <outputDirectory>../vagrant/deployments</outputDirectory> 
     </configuration> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.17</version> </plugin> </plugins> <resources> <resource> <directory>src/main/resources</directory> 
     <filtering>true</filtering> </resource> </resources> <testResources> <testResource> 
     <directory>src/test/resources</directory> <filtering>true</filtering> </testResource> 
     </testResources> </build> --> 

    <build> 
     <defaultGoal>test</defaultGoal> 
     <plugins> 
      <!-- The compiler plugin enforces Java 1.6 compatibility and controls 
       execution of annotation processors --> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.12</version> 
      </plugin> 
     </plugins> 
    </build> 



    <dependencyManagement> 

     <dependencies> 
      <!-- <dependency> <groupId>org.jboss.arquillian.extension</groupId> <artifactId>arquillian-rest-warp-bom</artifactId> 
       <version>1.0.0.Alpha2</version> <scope>import</scope> <type>pom</type> </dependency> --> 
      <dependency> 
       <groupId>org.jboss.shrinkwrap.resolver</groupId> 
       <artifactId>shrinkwrap-resolver-bom</artifactId> 
       <version>2.0.0-alpha-5</version> 
       <scope>import</scope> 
       <type>pom</type> 
      </dependency> 
      <dependency> 
       <groupId>org.jboss.arquillian</groupId> 
       <artifactId>arquillian-bom</artifactId> 
       <version>1.0.3.Final</version> 
       <scope>import</scope> 
       <type>pom</type> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 

    <dependencies> 
     <!-- <dependency> <groupId>org.jboss.arquillian.extension</groupId> <artifactId>arquillian-rest-warp-bom</artifactId> 
      <version>1.0.0.Alpha2</version> </dependency> --> 
     <dependency> 
      <groupId>org.jboss.shrinkwrap.resolver</groupId> 
      <artifactId>shrinkwrap-resolver-api</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.jboss.shrinkwrap.resolver</groupId> 
      <artifactId>shrinkwrap-resolver-impl-maven</artifactId> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.jboss.arquillian.junit</groupId> 
      <artifactId>arquillian-junit-container</artifactId> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.jboss.arquillian</groupId> 
      <artifactId>arquillian-junit</artifactId> 
      <scope>test</scope> 
      <version>1.0.0.Alpha5</version> 
     </dependency> 

     <dependency> 
      <groupId>ch.qos.logback</groupId> 
      <artifactId>logback-classic</artifactId> 
     </dependency> 
     <!-- F --> 

     <!-- Jax RS and REST API Related Dependencies --> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-jaxrs</artifactId> 
     </dependency> 

     <!-- Used by Jetty only. --> 

     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.jboss.spec</groupId> 
      <artifactId>jboss-javaee-6.0</artifactId> 
      <type>pom</type> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>company</groupId> 
      <artifactId>tricking-service</artifactId> 
      <version>${project.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>org.jboss.arquillian.container</groupId> 
        <artifactId>arquillian-weld-ee-embedded-1.1</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>org.jboss.weld</groupId> 
        <artifactId>weld-core</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <!-- <dependency> <groupId>com.wordnik</groupId> <artifactId>swagger-jaxrs_2.9.1</artifactId> 
      </dependency> --> 
     <dependency> 
      <groupId>com.wordnik</groupId> 
      <artifactId>swagger-annotations</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.wordnik</groupId> 
      <artifactId>swagger-core_2.9.1</artifactId> 
      <version>1.3.1</version> 
     </dependency> 
     <!-- <dependency> <groupId>org.jboss.arquillian.extension</groupId> <artifactId>arquillian-warp-impl</artifactId> 
      <scope>test</scope> </dependency> --> 

     <!-- <dependency> <groupId>org.jboss.arquillian.extension</groupId> <artifactId>arquillian-rest-warp-impl-resteasy</artifactId> 
      <scope>test</scope> </dependency> --> 
     <!-- <dependency> <groupId>org.jboss.arquillian.container</groupId> <artifactId>arquillian-glassfish-embedded-3.1</artifactId> 
      <version>1.0.0.CR3</version> <scope>test</scope> </dependency> <dependency> 
      <groupId>org.glassfish.main.extras</groupId> <artifactId>glassfish-embedded-all</artifactId> 
      <version>3.1.2</version> <scope>provided</scope> </dependency> --> 

     <!-- <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-arquillian-container-managed</artifactId> 
      <version>7.1.1.Final</version> <scope>test</scope> </dependency> --> 

    </dependencies> 
    <profiles> 
     <profile> 
      <id>arquillian-glassfish-embedded</id> 
      <dependencies> 
       <dependency> 
        <groupId>org.jboss.arquillian.container</groupId> 
        <artifactId>arquillian-glassfish-embedded-3.1</artifactId> 
        <version>1.0.0.CR3</version> 
        <scope>test</scope> 
       </dependency> 
       <dependency> 
        <groupId>org.glassfish.main.extras</groupId> 
        <artifactId>glassfish-embedded-all</artifactId> 
        <version>3.1.2</version> 
        <scope>provided</scope> 
       </dependency> 
       <!-- Enable dependency if you want to use H2 --> 
       <!-- Also update glassfish-resources.xml to use H2 connection information --> 
       <!-- <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> 
        <version>1.3.166</version> <scope>test</scope> </dependency> --> 
      </dependencies> 
      <build> 
       <testResources> 
        <testResource> 
         <directory>src/test/resources</directory> 
        </testResource> 
        <testResource> 
         <directory>src/test/resources-glassfish-embedded</directory> 
        </testResource> 
       </testResources> 
       <plugins> 
        <!-- The surefire plugin is configured to pass a system property to 
         GlassFish to retarget the derby log file --> 
        <plugin> 
         <artifactId>maven-surefire-plugin</artifactId> 
         <version>2.12</version> 
         <configuration> 
          <systemPropertyVariables> 
           <java.util.logging.config.file> 
            ${project.build.testOutputDirectory}/logging.properties 
           </java.util.logging.config.file> 
           <derby.stream.error.file> 
            ${project.build.directory}/derby.log 
           </derby.stream.error.file> 
          </systemPropertyVariables> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
     <profile> 
      <!-- Make sure that the default Derby database is started when you start 
       the GlassFish instance --> 
      <!-- You can start the database using this command: asadmin start-database --> 
      <id>arquillian-glassfish-remote</id> 
      <dependencies> 
       <dependency> 
        <groupId>org.jboss.spec</groupId> 
        <artifactId>jboss-javaee-web-6.0</artifactId> 
        <version>3.0.0.Final</version> 
        <type>pom</type> 
        <scope>provided</scope> 
        <exclusions> 
         <exclusion> 
          <groupId>xalan</groupId> 
          <artifactId>xalan</artifactId> 
         </exclusion> 
        </exclusions> 
       </dependency> 
       <dependency> 
        <groupId>org.jboss.arquillian.container</groupId> 
        <artifactId>arquillian-glassfish-remote-3.1</artifactId> 
        <version>1.0.0.CR3</version> 
        <scope>test</scope> 
       </dependency> 
      </dependencies> 
      <build> 
       <testResources> 
        <testResource> 
         <directory>src/test/resources</directory> 
        </testResource> 
        <testResource> 
         <directory>src/test/resources-glassfish-remote</directory> 
        </testResource> 
       </testResources> 
      </build> 
     </profile> 
     <profile> 
      <id>arquillian-jbossas-managed</id> 
      <dependencies> 
       <dependency> 
        <groupId>org.jboss.spec</groupId> 
        <artifactId>jboss-javaee-web-6.0</artifactId> 
        <version>3.0.0.Final</version> 
        <type>pom</type> 
        <scope>provided</scope> 
        <exclusions> 
         <exclusion> 
          <groupId>xalan</groupId> 
          <artifactId>xalan</artifactId> 
         </exclusion> 
        </exclusions> 
       </dependency> 
       <dependency> 
        <groupId>org.jboss.as</groupId> 
        <artifactId>jboss-as-arquillian-container-managed</artifactId> 
        <version>7.1.1.Final</version> 
        <scope>test</scope> 
       </dependency> 
       <dependency> 
        <groupId>org.jboss.arquillian.protocol</groupId> 
        <artifactId>arquillian-protocol-servlet</artifactId> 
        <scope>test</scope> 
       </dependency> 
      </dependencies> 
      <build> 
       <testResources> 
        <testResource> 
         <directory>src/test/resources</directory> 
        </testResource> 
        <testResource> 
         <directory>src/test/resources-jbossas-managed</directory> 
        </testResource> 
       </testResources> 
       <plugins> 
        <plugin> 
         <artifactId>maven-dependency-plugin</artifactId> 
         <executions> 
          <execution> 
           <id>unpack</id> 
           <phase>process-test-classes</phase> 
           <goals> 
            <goal>unpack</goal> 
           </goals> 
           <configuration> 
            <artifactItems> 
             <artifactItem> 
              <groupId>org.jboss.as</groupId> 
              <artifactId>jboss-as-dist</artifactId> 
              <version>7.1.1.Final</version> 
              <type>zip</type> 
              <overWrite>false</overWrite> 
              <outputDirectory>target</outputDirectory> 
             </artifactItem> 
            </artifactItems> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
     <profile> 
      <id>arquillian-jbossas-remote</id> 
      <dependencies> 
       <dependency> 
        <groupId>org.jboss.spec</groupId> 
        <artifactId>jboss-javaee-6.0</artifactId> 
        <version>1.0.0.Final</version> 
        <type>pom</type> 
        <scope>provided</scope> 
       </dependency> 
       <dependency> 
        <groupId>org.jboss.as</groupId> 
        <artifactId>jboss-as-arquillian-container-remote</artifactId> 
        <version>7.1.1.Final</version> 
        <scope>test</scope> 
       </dependency> 
       <dependency> 
        <groupId>org.jboss.arquillian.protocol</groupId> 
        <artifactId>arquillian-protocol-servlet</artifactId> 
        <scope>test</scope> 
       </dependency> 
      </dependencies> 
      <build> 
       <testResources> 
        <testResource> 
         <directory>src/test/resources</directory> 
        </testResource> 
        <testResource> 
         <directory>src/test/resources-jbossas-managed</directory> 
        </testResource> 
       </testResources> 
      </build> 
     </profile> 
    </profiles> 
</project> 

Und das ist eine Testklasse, die ich habe:

@RunWith(Arquillian.class) 
@RunAsClient 
public class TrickerResourceTest { 
    @Deployment 
    public static Archive<?> createDeployment() { 
     return ShrinkWrap.create(WebArchive.class, "test.war") 
      .addPackage(Tricker.class.getPackage()) 
      .addAsResource("test-persistence.xml", "META-INF/persistence.xml") 
      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); 
    } 

    @Test 
     public void getAllTrickers() throws Exception 
     { 
     Assert.assertTrue(true); 
     } 

} 

Das ist mein arquillian.xml

<arquillian xmlns="http://jboss.org/schema/arquillian" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://jboss.org/schema/arquillian 
     http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> 
    <container qualifier="jbossas-managed" default="true"> 
     <configuration> 
      <property name="jbossHome">target/jboss-as-7.1.1.Final</property> 
     </configuration> 
    </container> 
</arquillian> 

und dies ist mein Test-persitence:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://java.sun.com/xml/ns/persistence 
     http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> 
    <persistence-unit name="test"> 
     <!-- Use this jta-data-source if you're testing on JBoss AS 7.1 (setup by jbossas-ds.xml) --> 
     <jta-data-source>jdbc/arquillian</jta-data-source> 

     <!-- Use this jta-data-source if you're testing on JBoss AS 7.0 --> 
     <!-- Optionally, you can setup a DataSource with this name in your JBoss AS 7.0 installation --> 
     <!-- 
     <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source> 
     --> 
     <properties> 
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/> 
      <property name="hibernate.show_sql" value="true"/> 
     </properties> 
    </persistence-unit> 
</persistence> 

Das ist mein jbossas-ds.xml

<?xml version="1.0" encoding="UTF-8"?> 
<datasources xmlns="http://www.jboss.org/ironjacamar/schema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://www.jboss.org/ironjacamar/schema 
     http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd"> 
    <datasource enabled="true" 
     jndi-name="jdbc/arquillian" 
     pool-name="ArquillianEmbeddedH2Pool"> 
     <connection-url>jdbc:h2:mem:arquillian;DB_CLOSE_DELAY=-1</connection-url> 
     <driver>h2</driver> 
    </datasource> 
</datasources> 

Und ich will es auf JBoss laufen so auf cmd Ich sage:

mvn test -Parquillian-jbossas-managed 

Und die Fehler, die ich immer bin das ist:

Tests in error: 
    com.company.Trickservice.webapp.api.test.TrickerResourceTest: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor 

Vollstacktrace auf cmd:

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running com.company.trickservice.webapp.api.test.TrickerResourceTest 
12:36:29,500 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 
12:36:29,500 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 
12:36:29,500 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/Users/Elban/Documents/trick-services/web/target/classes/logback.xml] 
12:36:29,501 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath. 
12:36:29,501 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/C:/Users/Elban/Documents/trick-services/web/target/classes/logback.xml] 
12:36:29,501 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/C:/Users/Elban/.m2/repository/company/tricking-core/0.0.1-SNAPSHOT/tricking-co 
re-0.0.1-SNAPSHOT.jar!/logback.xml] 
12:36:29,550 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set 
12:36:29,556 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 
12:36:29,563 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT] 
12:36:29,573 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 
12:36:29,609 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to TRACE 
12:36:29,609 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT] 
12:36:29,610 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 
12:36:29,610 |-INFO in [email protected] - Registering current configuration as safe fallback point 

12:36:29.617 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider 
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.354 sec <<< FAILURE! 

Results : 

Tests in error: 
    com.company.trickservice.webapp.api.test.trickerResourceTest: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor 

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0 

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 27.390s 
[INFO] Finished at: Thu Jun 05 12:36:30 CEST 2014 
[INFO] Final Memory: 47M/300M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project tricker-services-webapp: There are test failures. 
[ERROR] 
[ERROR] Please refer to C:\Users\Elban\Documents\trick-services\web\target\surefire-reports for the individual test results. 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 
C:\Users\Elban\Documents\trick-services\web> 

Wenn Sie weitere Informationen benötigen, lassen Sie es mich wissen.

+0

Haben Sie den kompletten StackTrace? –

+0

hat es dort hinzugefügt. – Elsban

+0

versuchen, diese org.jboss.arquillian: arquillian-junit: 1.0.0.Alpha5 Abhängigkeit vollständig zu entfernen. –

Antwort

5

ich die Lösung gestern gefunden, damit ich es hier für den Fall, jemand anderes warf diesen Fehler geht beantworten werde:

Das Problem war, dass meine Tricker Klasse ein Feld vom Typ TrickerType hatte, und ich habe es sind nicht auf die Depotierung. So löste dies meine Frage:

@RunWith(Arquillian.class) 
@RunAsClient 
public class TrickerResourceTest { 
    @Deployment 
    public static Archive<?> createDeployment() { 
     return ShrinkWrap.create(WebArchive.class, "test.war") 
      .addPackage(Tricker.class.getPackage(), TrickerType.class.getPackage()) 
      .addAsResource("test-persistence.xml", "META-INF/persistence.xml") 
      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); 
    } 

    @Test 
     public void getAllTrickers() throws Exception 
     { 
     Assert.assertTrue(true); 
     } 

} 
+3

Um solche Probleme in Zukunft zu vermeiden, können Sie Ihre Klassen auf einmal hinzufügen, indem Sie 'archive.addPackages (true, new ExcludeRegExpPaths (". * Test.class $ "), PROJECT_ROOT_PACKAGE) ausführen;' This fügt alle Klassen hinzu, wenn PROJECT_ROOT_PACKAGE dein Root-Paket ist. Es erfordert einen Filter, um Testklassen nicht einzuschließen, da sie zum Zeitpunkt der Ausführung verfügbar sind. –

1

Ich hatte das gleiche Problem mit 1.1.4.Final und 1.0.3.Final von Arquillian-bom

<dependency> 
    <groupId>org.jboss.arquillian</groupId> 
    <artifactId>arquillian-bom</artifactId> 
    <version>${org.jboss.arquillian.bom.version}</version> 
    <type>pom</type> 
    <scope>import</scope> 
</dependency> 

Ich habe es kommentiert und ich bin mit :

<org.jboss.arquillian.junit.version>1.0.0.CR7</org.jboss.arquillian.junit.version> 
<org.jboss.arquillian.spi.version>1.0.0.Alpha5</org.jboss.arquillian.spi.version> 

<dependency> 
    <groupId>org.jboss.arquillian.junit</groupId> 
    <artifactId>arquillian-junit-container</artifactId> 
    <version>${org.jboss.arquillian.junit.version}</version> 
    <scope>test</scope> 
</dependency>      
<dependency> 
    <groupId>org.jboss.arquillian.protocol</groupId> 
    <artifactId>arquillian-protocol-servlet</artifactId> 
    <version>${org.jboss.arquillian.junit.version}</version> 
    <scope>test</scope> 
</dependency>  
<dependency> 
    <groupId>org.jboss.arquillian</groupId> 
    <artifactId>arquillian-spi</artifactId> 
    <version>${org.jboss.arquillian.spi.version}</version> 
    <scope>test</scope> 
</dependency>  

zu 1.0.0.CR7 von Arquillian-bom So Herabstufung sollte es beheben

<org.jboss.arquillian.bom.version>1.0.0.CR7</org.jboss.arquillian.bom.version> 
+0

Danke für das Aufzeigen von Problemen mit mehreren Versionen. Ich habe jetzt fast eine Stunde lang nach meinem Fehler gesucht - ich musste nur noch Arquillian von 1.1.8 auf 1.1.11 upgraden, was nun wie erwartet funktioniert. – cljk

0

Manchmal wird, wenn der Code kommentiert aus der IDE-Verknüpfung verwenden, könnte es passieren, dass die IDE (es mir mit Netbeans passiert) drei hinzufügen, wird „-“ anstelle von zwei, zB:

<!--  <property name="host">172.33.22.11</property> 
     <property name="port">8080</property>---> 

Dies war in meine arquillian.xml