I am migrating a java ear application from weblogic to jboss. The application is an ear with the below maven dependency on antlr in the pom:
<dependency> <groupId>antlr</groupId> <artifactId>antlr</artifactId> <version>2.7.7</version> <scope>test</scope> </dependency>
On localhost we use jetty so it gets included by the pom I guess due to the scope being test. In our test/production environments we deploy on Weblogic and I am trying to get it moved to jboss. The ear fails when deploying to jboss because weblogic includes this antlr jar automatically in the container and jboss does not. So for jboss build I have to comment out the scope line and include antlr directly in the ear file. I would like to not change the code and still have it work on both jboss and weblogic.
Is it possible to include the antlr dependency directly in jboss as a module or some other classpath setting?
Advertisement
Answer
Antlr is a base module so you can add it to your dependencies, jboss will make the module accessible to your application.
One way it so add the dependencies in the manifest of your jar file, in your maven build:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.1</version> <configuration> <archive> <manifestEntries> <Dependencies>org.antlr</Dependencies> </manifestEntries> </archive> </configuration> </plugin>
Alternatively you can add a jboss-deployment-structure.xml
file to your application and declare the dependency there.