How to add library in arquillian service deployment?

3.8k Views Asked by At

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)

I'm using jMockit 1.7 and have it in EAR deployment.

How can i add library in this deployment (arquillian-service)

PS: This deployment is managed by arquillian, i have nothing to do with it.

1

There are 1 best solutions below

3
On

I solved the problem of third-party libs as follows - the list of dependencies:

protected static final String[] DEPENDENCIES = {
        ...,
        "xbean:xbean:2.4.0",
        ...
};

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

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>