我当前正在尝试使用jboss wildfly运行arquillian测试,但在运行它时引发了java.lang.ArrayStoreException:sun.reflect.annotation.TypeNotPresentExceptionProxy异常。
我有以下配置:
jboss Wildfly-8.1.0.cr1
derby 10.9.1.0
为了使用derby networkServer(而不是内存),我在jboss Wildfly中部署了derbyclient.jar(name=derbyclient.jar,运行时名称:derbyclient.jar)
maven项目结构:
example
example-ear
example-ejb
example-web
Arquillian testcase包含在example-ejb项目中。
pom(arquillian-container is wildfly-arquillian-container-managed-8.0.0.final):
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
Arquillian JUnit测试用例:
...
@RunWith(Arquillian.class)
public class PersonIT {
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addPackage("example.util")
.addPackage("example.model")
.addPackage("example.model.constraints")
.addPackage("example.model.embeddables")
.addPackage("example.model.enumeration")
.addPackage("example.model.listeners")
.addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
.addAsResource("META-INF/default_mapping.xml", "META-INF/default_mapping.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
// Deploy our test datasource
.addAsWebInfResource("test-ds.xml", "test-ds.xml")
;
}
@PersistenceContext
private EntityManager em;
@Inject
private UserTransaction utx;
@Before
public void preparePersistenceTest() throws Exception {
clearData();
insertData();
startTransaction();
}
...
@After
public void commitTransaction() throws Exception {
utx.commit();
}
@Test
public void test1() throws Exception {
}
}
test-persistence.xml:
<?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="primary" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/npptDS</jta-data-source>
<mapping-file>META-INF/default_mapping.xml</mapping-file>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.scripts.create-target" value="chapter04Create.ddl"/>
<property name="javax.persistence.schema-generation.scripts.drop-target" value="chapter04Drop.ddl"/>
<property name="javax.persistence.sql-load-script-source" value="import.sql"/>
</properties>
</persistence-unit>
</persistence>
test-ds.xml(包含在ejb maven项目中):
<?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 jndi-name="java:jboss/datasources/npptDS"
pool-name="npptDS"
enabled="true"
use-java-context="true">
<connection-url>jdbc:derby://localhost:1527/nppt</connection-url>
<driver>derbyclient.jar</driver>
</datasource>
</datasources>
运行arquillian测试时出现异常:
07:26:45,536 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 11) HHH000400: Using dialect: org.hibernate.dialect.DerbyTenSevenDialect
07:26:45,545 WARN [org.hibernate.dialect.DerbyDialect] (ServerService Thread Pool -- 11) HHH000328: Unable to load/access derby driver class sysinfo to check versions : org.apache.derby.tools.sysinfo from [Module "org.hibernate:main" from local module loader @43a2a89a (finder: local module finder @6beb3926 (roots: D:\05_programme\jboss\wildfly-8.1.0.CR1\modules,D:\05_programme\jboss\wildfly-8.1.0.CR1\modules\system\layers\base))]
07:26:45,604 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 11) MSC000001: Failed to start service jboss.persistenceunit."test.war#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."test.war#primary": java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.1.0.CR1.jar:8.1.0.CR1]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.1.0.CR1.jar:8.1.0.CR1]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_45]
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.1.0.CR1.jar:8.1.0.CR1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:673) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:480) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) [rt.jar:1.7.0_45]
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3178) [rt.jar:1.7.0_45]
at java.lang.Class.getAnnotation(Class.java:3137) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:131) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:84) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:221) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) [rt.jar:1.7.0_45]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) [rt.jar:1.7.0_45]
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3178) [rt.jar:1.7.0_45]
at java.lang.Class.getAnnotations(Class.java:3158) [rt.jar:1.7.0_45]
at org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader.getPhysicalAnnotations(JPAOverriddenAnnotationReader.java:2975) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader.initAnnotations(JPAOverriddenAnnotationReader.java:345) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader.isAnnotationPresent(JPAOverriddenAnnotationReader.java:326) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.annotations.common.reflection.java.JavaXAnnotatedElement.isAnnotationPresent(JavaXAnnotatedElement.java:60)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.syncAnnotatedClasses(Configuration.java:3723) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1409) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:397) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.1.0.CR1.jar:8.1.0.CR1]
... 8 more
07:26:45,617 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "test.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"test.war#primary\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"test.war#primary\": java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy"}}
07:26:45,619 ERROR [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "test.war" was rolled back with the following failure message:
{"JBAS014671: Failed services" => {"jboss.persistenceunit.\"test.war#primary\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"test.war#primary\": java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy"}}
07:26:45,626 INFO [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016009: Stopping weld service for deployment test.war
07:26:45,659 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 11) JBAS011410: Stopping Persistence Unit (phase 1 of 2) Service 'test.war#primary'
07:26:45,662 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010409: Unbound data source [java:jboss/datasources/npptDS]
07:26:45,698 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment test.war (runtime-name: test.war) in 78ms
07:26:45,702 INFO [org.jboss.as.controller] (management-handler-thread - 2) JBAS014774: Service status report
...
提前道谢。
问候你,麦克斯
我已经解决了。问题是在微部署中缺少一个包。
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addPackage("example.util")
.addPackage("example.model")
.addPackage("example.model.constraints")
.addPackage("example.model.embeddables")
.addPackage("example.model.enumeration")
.addPackage("example.model.listeners")
.addPackage("example.model.validator")
.addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
.addAsResource("META-INF/default_mapping.xml", "META-INF/default_mapping.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
// Deploy our test datasource
.addAsWebInfResource("test-ds.xml", "test-ds.xml")
;
}
异常消息不好。消息中缺少上下文。所以也许hibernate应该记录当前正在处理的类或其他东西。
org.hibernate.cfg.annotations.reflection.JPAOverrideAnnotationReader
private void initAnnotations() {
if ( annotations == null ) {
XMLContext.Default defaults = xmlContext.getDefault( className );
if ( className != null && propertyName == null ) {
//is a class
Element tree = xmlContext.getXMLTree( className );
Annotation[] annotations = getPhysicalAnnotations();
...
}
Arquillian 可让你在远程或者嵌入式的容器里测试业务逻辑,同时可作为一个压缩包发布到容器中,并通过客户端来进行交互测试。 Arquillian 是一个可以方便的在现有类基础性扩展测试用例,基于 JUnit 。 示例代码: @RunWith(org.jboss.arquillian.junit.Arquillian.class)public class TemperatureConverte
在tome远程上执行具有阿奎利安的测试用例时,我得到以下异常 似乎没有与部署相关的其他异常。使用以下 maven 依赖项 arquillian-junit-container 1.1.9 arquillian-tomee-remote
我在一株嵌入的野花上做了阿奎利亚测试。尽管所有移植脚本、集成器类(flyway在其中安装)和所有FlyWay包(来自POM文件)都包含在。war文件(部署在嵌入式wildfly上),不进行迁移。 这有什么原因吗?这是原则上不起作用还是我错过了什么? 我喜欢实现的是,arquillian运行的自动测试将设置一个内存数据库,其方案与使用相同迁移脚本的生产数据库相同。 编辑:正如ytg下面所问的,我添加
我配置了两个项目来使用最新的jacoco版本0.7.8和最新的Arquillian jacoco扩展(1.0.09Alpha)。它就像一个魔咒(适用于jenkins和sonar 6.2)!但我有一个更大的项目,当我只启动Arquillian IT测试时,我的war归档文件会被创建,并有所有的类和测试。好的,当我运行相同的测试时,它的代码覆盖率,Arquillian归档文件中不包含任何类,并且有以下
我试图使用Arquillian框架编写一个简单的Widlfly容器测试。我已经遵循了Wildfly容器测试指南中的指南。 得到的pom.xml如下所示。
我正在尝试使用Arquillian Framework和Cucumber构建一个maven项目。我收到此消息: 终端的PrintSc 我能做些什么来解决这个问题?