Pom.xml dependencies relation with jboss-deployment-structure.xml

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6
    • 7

Issue

  • I have an application that has the following dependency in our pom.xml, but when I deploy our application, it comes up with a java.lang.ClassNotFoundException because there is no dependency on this module in my jboss-deployment-structure.xml file. How do we get this to be generated correctly?
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>2.3.10.Final-redhat-1</version>
    <scope>provided</scope> 
</dependency>

Resolution

Although they are both called "dependencies", there is no relationship between a Maven dependency in pom.xml and a JBoss EAP module dependency in jboss-deployment-structure.xml. The pom file is correct, JBoss EAP modules should be defined using <scope>provided</scope> which is used to compile time to tell Maven that the jar should not be packaged in the application as it will be provided at runtime by the application server.

It's also necessary to add the module dependency in jboss-deployment-structure.xml as this is what causes the module to be made visible at runtime by the application.

See How to specify a dependency on a JBoss Module in JBoss EAP 6 / 7.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.