Reputation: 4689
I am using Arquillian[1] in a Glassfish-environment to have my Code unit-tested.
I have setup my tests to work fine when being run in glassfish-embedded environment. But when I try to execute the tests in remote-Glassfish-environment, maven-Dependencies are not found:
Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Lorg/springframework/data/neo4j/support/Neo4jTemplate;
My ShrinkWrap from the test:
@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class).addPackages(true, "main.java")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
}
To have maven dependencies resolved I am using shrinkwrap-resolver-bom:shrinkwrap-resolver-bom - it seems to me as if the maven dependencies are not in classpath when running the test in remote-environment.
I have upload my pom.xml to http://pastxt.com/P/9400A0KQSC
How can I get my test running in Glassfish-remote-environment?
Upvotes: 1
Views: 3160
Reputation: 76709
Having the ShrinkWrap Resolver BOM in your POM is not sufficient to enable Arquillian locate and add Maven artifacts to your deployment. A Maven BOM (Bill of Materials) is a merely a container for related dependencies.
To use the BOM, you'll need to import the BOM into your project POm in the dependencyManagement
section, and add the dependencies that you need. To add the ShrinkWrap Maven resolver, you'll need to add the shrinkwrap-resolver-depchain
test dependency.
You'll need to use the Maven resolver to resolve the dependencies you need, and then add the resolved artifacts to your ShrinkWrap archive. More details about using the newer ShrinkWrap Maven resolver (2.x) are in this community FAQ post. Note that the Arquillian BOM (<= 1.0.3.Final) pulls in an older version of the ShrinkWrap resolvers, so you'll need to be careful about which version of the ShrinkWrap Maven resolver you pull in.
Upvotes: 2