0

I have Multi Module Maven Project and in the parent pom.xml I am importing Wildfly dependency like below -

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

When I try to run mvn install the sub modules start failing with compilation errors -

package javax.servlet.http does not exist
package org.apache.commons.beanutils does not exist
package javax.xml.ws does not exist
package javax.mail does not exist
package javax.mail.internet does not exist

Note: I have not mentioned any dependencies in the child pom.xml.

If we check the Wildfly Server zip all these jars are present under the modules directory, so probably they should get downloaded via maven as well.

I read other posts also on StackOverflow like How to use jars from Wildfly correctly in Maven? , but it didn't help much.

Please let me know if I am missing something or doing things wrongly.

Dusayanta Prasad
  • 349
  • 3
  • 15
  • Importing the BOM doesn’t add any dependencies - it just adds what is essentially a `dependencyManagent` block. You need to add the dependencies themselves somewhere. – Boris the Spider Jun 03 '22 at 19:41
  • 1
    The specific dependencies you mention should be added as a `provided` scope as the web server will provide its versions at run time. It’s actually an error to include Javax dependencies in your war. – Boris the Spider Jun 03 '22 at 19:42
  • @BoristheSpider I want to use the dependencies only during build time and I am not going to create an uber jar/war. – Dusayanta Prasad Jun 03 '22 at 19:52
  • Also, if you provide an example on how I need to use the dependency in the sub module ```pom.xml``` so that it downloads all the related jar and doesn't error out during compilation. – Dusayanta Prasad Jun 03 '22 at 19:54
  • @DusayantaPrasad You only need to reference your dependencies without their `` tag, because they are alredy set inside the parent pom. – BendaThierry.com Jun 05 '22 at 15:45
  • Also, don't use the parent POM to load dependencies. Not all those dependencies should be used in your application. It's better to use the the [bom](https://github.com/wildfly/boms) or the Jakarta EE BOM. – James R. Perkins Jun 05 '22 at 20:47

0 Answers0