无法创建类的新实例org.jboss.arquillian.test.impl.EventTestRunnerAdaptor [英] Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor

查看:872
本文介绍了无法创建类的新实例org.jboss.arquillian.test.impl.EventTestRunnerAdaptor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个pom.xml文件

 < project xmlns =http://maven.apache.org/ POM / 4.0.0xmlns: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>特技< / finalName> <插件> <插件> <&的groupId GT; org.apache.maven.plugins< /&的groupId GT;
< artifactId> maven-war-plugin< / artifactId> <结构> <输出目录> ../流浪/部署< /输出目录>
< / configuration> < /插件> <插件> < artifactId的>行家-万无一失-插件< / artifactId的>
< version> 2.17< / version> < /插件> < /插件> <资源> <资源> <目录> SRC /主/资源< /目录>
< filtering> true< / filtering> < /资源> < /资源> < testResources> < testResource>
< directory> src / test / resources< / directory> <滤波>真< /过滤> < / testResource>
< / testResources> < /构建> - >

< build>
< defaultGoal> test< / defaultGoal>
< plugins>
<! - 编译器插件强制执行Java 1.6兼容性并控制注释处理器的
执行 - >
< 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 GT; org.jboss.arquillian.extension< /&的groupId GT; < artifactId的>的Arquillian静止翘曲-BOM< / artifactId的>
< version> 1.0.0.Alpha2< / version> <范围>输入(im​​port)LT /范围> <类型> POM< /类型> < /依赖性> - >
< 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 GT; org.jboss.arquillian.extension< /&的groupId GT; < artifactId的>的Arquillian静止翘曲-BOM< / artifactId的>
< version> 1.0.0.Alpha2< / version> < /依赖性> - >
< 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>

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

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

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

<! - Jax RS和REST API相关的依赖关系 - >
< dependency>
< groupId> org.jboss.resteasy< / groupId>
< artifactId> resteasy-jaxrs< / artifactId>
< / dependency>

<! - 仅供Jetty使用。 - >

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

<依赖>
< groupId> org.jboss.spec< / groupId>
< artifactId> jboss-javaee-6.0< / artifactId>
< type> pom< / type>
< scope>提供< / 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 GT; com.wordnik< /&的groupId GT; < artifactId的>招摇-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 GT; org.jboss.arquillian.extension< /&的groupId GT; < artifactId的>的Arquillian-经IMPL< / artifactId的>
< scope> test< / scope> < /依赖性> - >

<! - < dependency> <&的groupId GT; org.jboss.arquillian.extension< /&的groupId GT; < artifactId的>的Arquillian静止-经IMPL-RestEasy的< / artifactId的>
< scope> test< / scope> < /依赖性> - >
<! - < dependency> <&的groupId GT; org.jboss.arquillian.container< /&的groupId GT; < artifactId的>的Arquillian-的glassfish包埋-3.1< / artifactId的>
< version> 1.0.0.CR3< / version> <范围>试验< /范围> < /依赖性> <依赖性>
< groupId> org.glassfish.main.extras< / groupId> < artifactId的>与GlassFish嵌入所有< / artifactId的>
< version> 3.1.2< / version> <范围>条件< /范围> < /依赖性> - >

<! - < dependency> <&的groupId GT; org.jboss.as< /&的groupId GT; < artifactId的> JBoss的-AS-的Arquillian容器管理< / artifactId的>
< version> 7.1.1.Final< / version> <范围>试验< /范围> < /依赖性> - >

< / 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>提供< / scope>
< / dependency>
<! - 如果你想使用H2,启用依赖关系 - >
<! - 同时更新glassfish-resources.xml以使用H2连接信息 - >
<! - < dependency> <&的groupId GT; com.h2database< /&的groupId GT; < artifactId的> H2< / artifactId的>
< version> 1.3.166< / version> <范围>试验< /范围> < /依赖性> - >
< / dependencies>
< build>
< testResources>
< testResource>
< directory> src / test / resources< / directory>
< / testResource>
< testResource>
< directory> src / test / resources-glassfish-embedded< / directory>
< / testResource>
< / testResources>
< plugins>
<! - surefire插件配置为将系统属性传递给
GlassFish以重新定位derby日志文件 - >
< 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>
<! - 确保在启动
GlassFish实例时启动默认的Derby数据库 - >
<! - 您可以使用以下命令启动数据库: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>提供< / 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>提供< / 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>提供< / 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>

这是我的测试类:

  @RunWith(Arquillian.class)
@RunAsClient
public class TrickerResourceTest {
@Deployment
public static Archive<?> ; createDeployment(){
返回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()抛出异常
{
Assert.assertTrue(true);
}

}

这是我的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。组织/架构/的Arquillian / arquillian_1_0.xsd>
< container qualifier =jbossas-manageddefault =true>
< configuration>
< property name =jbossHome> target / jboss-as-7.1.1.Final< / property>
< / configuration>
< / container>
< / arquillian>

这是我的测试持久性:

 <?xml version =1.0encoding =UTF-8?> 
< persistence version =2.0xmlns =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_2_0.xsd>
< persistence-unit name =test>
<! - 如果您在JBoss AS 7.1上测试(由jbossas-ds.xml设置),请使用此jta-data-source - >
< jta-data-source> jdbc / arquillian< / jta-data-source>

<! - 如果您在JBoss AS 7.0上进行测试,请使用此jta-data-source - >
<! - 您可以选择在JBoss AS 7.0安装中使用此名称设置DataSource - >
<! -
< jta-data-source> java:jboss / datasources / ExampleDS< / jta-data-source>
- >
< properties>
< property name =hibernate.hbm2ddl.autovalue =create-drop/>
< property name =hibernate.show_sqlvalue =true/>
< / properties>
< / persistence-unit>
< / persistence>

这是我的jbossas-ds.xml

 <?xml version =1.0encoding =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>

我想在JBoss上运行它,所以在cmd我说:

  mvn test -Parquillian-jbossas-managed 

我得到的错误是:

 测试错误:
com.company .Trickservice.webapp.api.test.TrickerResourceTest:无法创建类的新实例org.jboss.arquillian.test.impl.EventTestRunnerAdaptor

cmd上的完整堆栈跟踪:

  ------------- ------------------------------------------ 
TESTS
------------------------------------------------- ------
运行com.company.trickservice.webapp.api.test.TrickerResourceTest
12:36:29,500 | -INFO in ch.qos.logback.classic.LoggerContext [default] - 无法找到资源[logback.groovy]
12:36:29,500 | -INFO in ch.qos.logback.classic.LoggerContext [default] - 无法找到资源[logback-test.xml]
12:36:29,500 | -INFO在ch.qos.logba中ck.classic.LoggerContext [default] - 在[file:/ C:/Users/Elban/Documents/trick-services/web/target/classes/logback.xml]找到资源[logback.xml]
12: 36:29,501 | -WARN in ch.qos.logback.classic.LoggerContext [default] - 资源[logback.xml]在类路径上多次出现。
12:36:29,501 | -WARN in ch.qos.logback.classic.LoggerContext [default] - Resource [logback.xml]发生在[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]发生在[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属性未设置
12:36:29,556 | -INFO in ch.qos.logback.core.joran .action.AppenderAction - 关于实例化[ch.qos.logback.core.ConsoleAppender]类型的appender
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 - 假设默认类型[ch.qos.logback.classic.encoder.PatternLayoutEncoder]为[编码器]属性
12:36:29,60 9 | -INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - 将ROOT记录器的级别设置为TRACE
12:36:29,609 | -INFO in ch.qos.logback.core.joran.action .AppenderRefAction - 将名为[STDOUT]的appender附加到Logger [ROOT]
12:36:29,610 | -INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - 配置结束。
12:36:29,610 | -INFO in ch.qos.logback.classic.joran.JoranConfigurator@74af72d8 - 将当前配置注册为安全回退点

12:36:29.617 [main] DEBUG org.jboss.logging - 记录提供者:org.jboss.logging.Slf4jLoggerProvider
测试运行:1,失败:0,错误:1,跳过:0,经过的时间:0.354秒<<<失败!

结果:

测试错误:
com.company.trickservice.webapp.api.test.trickerResourceTest:无法创建类org.jboss的新实例.arquillian.test.impl.EventTestRunnerAdaptor

测试运行:1,失败:0,错误:1,跳过:0

[INFO] ------- -------------------------------------------------- ---------------
[INFO] BUILD FAILURE
[INFO] ------------------- -------------------------------------------------- ---
[INFO]总时间:27.390s
[INFO]完成时间:Thu Jun 05 12:36:30 CEST 2014
[INFO]最终记忆:47M / 300M
[INFO] --------------------------------------------- ---------------------------
[错误]无法执行目标org.apache.maven.plugins:maven-surefire-插件:2.12:项目tricker-services-webapp上的test(default-test):存在测试失败。
[错误]
[错误]请参阅C:\ Users\Elban \Documents\trick-services \web \ target &\\surefire-reports了解各个测试结果。
[错误] - > [帮助1]
[错误]
[错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。
[错误]使用-X开关重新运行Maven以启用完整的调试日志记录。
[错误]
[错误]有关错误和可能解决方案的更多信息,请阅读以下文章:
[错误] [帮助1] http://cwiki.apache.org / confluence / display / MAVEN / MojoFailureException
C:\ Users \Elban \Documents\trick-services \web>

如果您需要更多信息,请告诉我们。

解决方案

昨天我找到了解决方案,所以我会在这里回答,以防其他人投掷此错误:



<问题是我的Tricker类有一个TrickerType类型的字段,我没有将它包含在Depoyment中。所以,这解决了我的问题:

  @RunWith(Arquillian.class)
@RunAsClient
公共课TrickerResourceTest {
@Deployment
public static Archive<?> createDeployment(){
返回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()抛出异常
{
Assert.assertTrue(true);
}

}


I have this pom.xml file

<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>

And this is a test class that I have:

@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);
      }

}

This is my 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>

and this is my 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>

This is my 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>

And I want to run it on JBoss so on cmd I am saying:

mvn test -Parquillian-jbossas-managed

And the error that I am getting is this:

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

Full stacktrace on 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 ch.qos.logback.classic.joran.JoranConfigurator@74af72d8 - 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>

If you need any more information, just let me know.

解决方案

I found the solution yesterday so I'll answer it here in case anyone else goes threw this error:

The problem was that my Tricker class had a field of type TrickerType and I did not include it on the Depoyment. So, this solved my issue:

@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);
      }

}

这篇关于无法创建类的新实例org.jboss.arquillian.test.impl.EventTestRunnerAdaptor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆