I follow the example on the maven-ear-plugin site, which shows how to add third-party libraries to the generated application.xml . However, it does not seem to work as I expected. In the same way, the contextRoot web module is ignored .
According to the documentation , what I'm trying to do should be completely possible.
The web module context root can be configured using contextRoot.
Please note that third-party libraries (e.g. JarModule) are not included in the generated application.xml (only ejb-client should be included in the java entry). However, the jar dependency in the generated application.xml can be enabled by specifying the includeInApplicationXml flag .
I have the following output when it builds in my application.xml application.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd"> <application> <display-name>MyApp.EAR</display-name> <module> <ejb>MyApp.jar</ejb> </module> <module> <web> <web-uri>MyApp.war</web-uri> <context-root>/MyApp.Web</context-root> </web> </module> </application>
From the following maven configuraton (pom.xml).
... <modelVersion>4.0.0</modelVersion> <groupId>com.blah</groupId> <artifactId>MyApp.EAR</artifactId> <version>1.0</version> <packaging>ear</packaging> <build> <plugins> <plugin> <groupId>maven-ear-plugin</groupId> <artifactId>maven-ear-plugin</artifactId> <version>2.7</version> <configuration> <applicationName>MyApp</applicationName> <modules> <ejbModule> <groupId>com.blah</groupId> <artifactId>MyApp.EJB</artifactId> </ejbModule> <webModule> <groupId>com.blah</groupId> <artifactId>MyApp.Web</artifactId> <contextRoot>MyApp</contextRoot> </webModule> <jarModule> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <includeLibInApplicationXml>true</includeLibInApplicationXml> </jarModule> </modules> <archive> <manifestEntries> <WebLogic-Application-Version>${weblogic.version}</WebLogic-Application-Version> </manifestEntries> </archive> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>com.blah</groupId> <artifactId>MyApp.EJB</artifactId> <version>1.0</version> <type>ejb</type> </dependency> <dependency> <groupId>com.blah</groupId> <artifactId>MyApp.Web</artifactId> <version>1.0</version> <type>war</type> </dependency> </dependencies> ...
It’s immediately obvious that application.xml is not created as I intended.
- An invalid contextRoot is specified in the application.xml application, instead of which MyApp.Web is displayed instead of MyApp.
- The specified jarModule org.slf4j is completely missing from application.xml.
What am I doing wrong?
Debugging from Maven is shown below.
[DEBUG] ----------------------------------------------------------------------- [DEBUG] Goal: org.apache.maven.plugins:maven-ear-plugin:2.4.2:generate-application-xml (default-generate-application-xml) [DEBUG] Style: Regular [DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?> <configuration> <description>${project.description}</description> <displayName>${project.artifactId}</displayName> <encoding default-value="UTF-8"/> <generatedDescriptorLocation>${project.build.directory}</generatedDescriptorLocation> <includeLibInApplicationXml default-value="false"/> <project>${project}</project> <version default-value="1.3"/> <workDirectory>${project.build.directory}/${project.build.finalName}</workDirectory> </configuration>
PS I tried to create the maven-ear-plugin tag, but that didn’t allow me, because I am not authoritative enough! If someone could create this, I would be grateful.