Reputation: 782
I have set up a WildFly Maven project with a local dependency. I compile the library (mvn compile
) which is used as a local dependency and install it (mvn install
) in the local Maven repository. Doing this allows me to successfully compile the WildFly project using Maven. The problem I encounter is that it fails to deploy (mvn wildfly:deploy
), because it can't find the classes referenced in the local library, throwing a NoClassDefFoundError exception as result.
The library dependency is included as follows:
<dependency>
<groupId>mygroup</groupId>
<artifactId>library</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
I'm using the WildFly Maven plugin. Is there anything I should be doing differently?
Upvotes: 2
Views: 1615
Reputation: 5150
<scope>provided</scope>
- when you say provided you are saying that this lib will be available at runtime and does not need to be compiled with the current jar.
Hence what the artifact that you build using mvn compile/install
will not include that library
dependency.
This means that the application container(wildfly) you are running in must provide the jar.
You are getting the error because you havn't provided
the library.jar
in your application container nor have to included in your build file.
There are two solutions:
Explicitly defined the dependency in you jboss configuration: https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html/Development_Guide/Add_an_Explicit_Module_Dependency_to_a_Deployment1.html
Change the scope from provided to compile: <scope> compile </scope>
Upvotes: 3