Adding dependencies to .jar in arquillian
rune_rne May 11, 2012 9:25 AMhi,
i try to write some integration test in these test i try to use some .jar files as libraries for the functions i want to test.
I do this in eclipse without mave using ivy.
my bean looks like this:
@Stateless public class TestBean{ static{ PceLogger newLogger = new PceLogger(); } public static void testDia(){ newLogger.something(); } }
my test looks like this:
@Deployment public static WebArchive createTestArchive() { MavenDependencyResolver resolver = DependencyResolvers .use(MavenDependencyResolver.class); WebArchive war = ShrinkWrap.create(WebArchive.class, "TestBean.war").addClass(TestBean.class) .addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class) .artifacts("/WEB-INF/lib/A.jar","/WEB-INF/lib/B.jar","/WEB-INF/lib/C.jar").resolveAs(WebArchive.class)) .addAsManifestResource(EmptyAsset.INSTANCE,ArchivePaths.create("beans.xml")) .addAsManifestResource("newTest/web.war/META-INF/MANIFEST.MF"); return war; } @EJB private TestBean testBean; @Test public void test() throws Exception { Assert.assertNotNull(testBean); }
Further i put the jar into the build path and aswell i tried to put the path into the MANIFEST
i already tried to run the deployment with:
.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class)
.artifacts("/WEB-INF/lib/A.jar","/WEB-INF/lib/B.jar","/WEB-INF/lib/C.jar").resolveAs(WebArchive.class))
which results in:
java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive JunitTestCase.createTestArchive()
Caused by: java.lang.reflect.InvocationTargetException
Caused by: org.jboss.shrinkwrap.resolver.api.ResolutionException: Bad artifact coordinates, expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]][:<version>]
and with
.addAsLibraries("/WEB-INF/lib/A.jar","/WEB-INF/lib/B.jar","/WEB-INF/lib/C.jar").resolveAs(WebArchive.class))
which results in the same
when i run it wihtout the addAsLibraries i get:
Failed to start service jboss.deployment.unit."TestBean.war".
Caused by: java.lang.NoClassDefFoundError:
but it is not working
any suggestions?