How to use jars from Wildfly correctly in Maven?

EdwinW picture EdwinW · Sep 3, 2014 · Viewed 10.4k times · Source

I'm working on a project to deploy to Wildfly, and I'm using Maven to build it. This is a complex project with multiple war/jar/ear files, so there's a parent pom.xml with the following in it:

...
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.wildfly.bom</groupId>
      <artifactId>jboss-javaee-7.0-with-all</artifactId>
      <version>8.1.0.Final</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
...
  </dependencies>
</dependencyManagement>
...

Unfortunately, the above BOM does not include various jar files that I know are in the default Wildfly 8.1.0.Final distribution. In particular, the cause of this question is the cxf-api jar file. I know it resides at this location in Wildfly:

wildfly-8.1.0.Final/modules/system/layers/base/org/apache/cxf/main/cxf-api-2.7.11.jar

but it is not being managed by the BOM recommended for Wildfly.

How do I correctly add cxf-api, and similar jar files, to the project's pom.xml, preferably without having to specify each one individually? Sure, I could do something like this:

<dependency>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-api</artifactId>
  <version>2.7.11</version>
  <scope>provided</scope>
</dependency>

but I'd really rather not have to do this for each and every jar file that is already a part of Wildfly.

Isn't there a BOM that I can import?

Answer

tmarouane picture tmarouane · Sep 5, 2014

WildFly BOMs (aka JBoss Bill of Materials in its original version) is a set of dependencies used to enhance deployment of dependant projects and automate in some way their tests. It does not unfortunately includes dependencies used in WildFly core i.e. the Application Server.

The pom.xml (project descriptor) that you really need to import just the way you did for your BOMs pom file is the WildFly parent pom. So just import it into your own project pom and you will have your dependecies transitevelly resolved:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.wildfly</groupId>
      <artifactId>wildfly-parent</artifactId>
      <version>8.1.0.Final</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

Checkout the Apache CXF version used in the target WildFly version and just pick up the stable tags that match your needs.