问题描述
我目前正在使用Arquillian用于jboss(远程),我正在努力让Jmockit工作。我部署了一个工作正常的耳朵,但我收到arquillian-service的错误:
i'm currently using Arquillian for jboss(remote) and i'm trying to make Jmockit work. I deployed an ear which works fine, but i'm getting this error for arquillian-service:
java.lang.NoClassDefFoundError: mockit/internal/state/TestRun
Caused by: java.lang.ClassNotFoundException: mockit.internal.state.TestRun from
[Module "deployment.arquillian-service:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
我正在使用jMockit 1.7并在EAR部署中使用它。
I'm using jMockit 1.7 and have it in EAR deployment.
如何在此部署中添加库(arquillian-service)
How can i add library in this deployment (arquillian-service)
PS:这个部署由arquillian管理,我与它无关。
PS: This deployment is managed by arquillian, i have nothing to do with it.
推荐答案
我解决了第三方库的问题如下 -
依赖列表:
I solved the problem of third-party libs as follows - the list of dependencies:
protected static final String[] DEPENDENCIES = {
...,
"xbean:xbean:2.4.0",
...
};
将所有这些包装到单独的jar中的方法:
Method which packs all them into separate jar:
protected JavaArchive thirdPartyLibs() {
JavaArchive lib = ShrinkWrap.create(JavaArchive.class, "libs.jar");
for (String dependency : DEPENDENCIES) {
lib.merge(Maven.resolver().resolve(dependency).withoutTransitivity().asSingle(JavaArchive.class));
}
return lib;
}
最后我在包装核心jar时合并它:
Eventually I merge it when packing core jar:
protected JavaArchive createJar() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addAsManifestResource("META-INF/test-persistence.xml", ArchivePaths.create("persistence.xml"))
.addAsManifestResource("META-INF/test-beans.xml", ArchivePaths.create("beans.xml"))
.....
.merge(thirdPartyLibs());
}
还必须指出使用下一个依赖项:
Also to use this next dependencies must be pointed out:
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId>
<version>2.1.1</version>
<scope>test</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
<scope>test</scope>
</dependency>
这篇关于如何在arquillian服务部署中添加库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!