Maven resolver works fine from command line but mess up module dependency in a multi-module project
psilvestru Jul 9, 2014 1:13 AMHello,
I have a multi-module project in which I use Arquillian for integration testing. The tests are running fine if started from command line but if I try to execute a test from Eclipse it fails with the following exception:
Caused by: java.lang.Exception: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"crm-test.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"crm-test.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"crm-test.war\"
Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class com.monkeyz.msp.crm.impl.services.internal.CrmInternalServiceBean with ClassLoader ModuleClassLoader for Module \"deployment.crm-test.war:main\" from Service Module Loader
Caused by: java.lang.LinkageError: Failed to link com/monkeyz/msp/crm/services/ClientManagementException (Module \"deployment.crm-test.war:main\" from Service Module Loader)
Caused by: java.lang.NoClassDefFoundError: com/monkeyz/utils/exceptions/AbstractCheckedException
Caused by: java.lang.ClassNotFoundException: com.monkeyz.utils.exceptions.AbstractCheckedException from [Module \"deployment.crm-test.war:main\" from Service Module Loader]"}}
I use the following code to create the deployment archive:
WebArchive archive = ShrinkWrap .create(WebArchive.class, "crm-test.war"); | |
// add packages | |
archive.addPackage(CrmManagementService.class.getPackage()); | |
archive.addPackage(CrmInternalServiceBean.class.getPackage()); | |
archive.addPackage(ClientEntity.class.getPackage()); | |
archive.addPackage(Client.class.getPackage()); |
// add maven dependencies | |
PomEquippedResolveStage pom = Maven.resolver().loadPomFromFile( "pom.xml"); |
File[] libs = pom.resolve("com.monkeyz.msp:utils:0.0.1-SNAPSHOT") .withClassPathResolution(true).withTransitivity().asFile(); | |
archive.addAsLibraries(libs); | |
// add persistence related resources | |
archive.addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml"); | |
// add WEB related resources | |
archive.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); | |
archive.addAsWebInfResource("test-ds.xml", "test-ds.xml"); |
From command line it resolves the utils dependency OK but from eclipse I got included a file utils-4076251260393477154.jar which is a corrupted jar file.
Playing around I saw that it seems to resolve correctly the artifact (MavenResolvedArtifact had the right properties) and everything is messed up when calling asFile method.
What am I doing wrong ?
Thanks,
Silvestru