I declared a custom jboss-app.xml in my pom.xml, but the plugin is generating an internal and empty jboss-app.xml file into ear/META-INF.
I created my pom.xml based on this article with the following definition:
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<data-sources>
<data-source>${artifactId}/src/main/resources/mytest-ds.xml</data-source>
</data-sources>
<jboss>${artifactId}/src/main/resources/jboss-app.xml</jboss>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<modules>
<ejbModule>
<groupId>com.testproject</groupId>
<artifactId>ejb-project</artifactId>
</ejbModule>
</modules>
</configuration>
</plugin>
But, I can't handle my custom jboss-app.xml. A new is empty descriptor (without defined ejbs) is generated every time.
You should be able to simply include your jboss-app.xml in your source tree and Maven will pull it in.
Your project directory structure for the maven-ear-plugin should look like:
|-- pom.xml
`-- src
`-- main
`-- application
`-- META-INF
|-- application.xml
`-- jboss-app.xml
Then just run mvn package to create your EAR. Assuming the packaging for your pom.xml is 'ear' it will pull jboss-app.xml into your resulting ear.
Also, I believe your <datasources>...</datasources> configuration needs to be within the <jboss>...</jboss> tags.
See also: http://maven.40175.n5.nabble.com/Deployment-of-the-jboss-app-xml-file-td45009.html
From the docs, it looks like jboss tag triggers the generation of jboss-app.xml. How about omitting this tag and generating the ear?
Alternative would be to pull datasources via application.xml as described here. But as <jarModule> requires are full-blown maven artifact, that is longer way (perhaps for application servers other than JBoss):
• project/ds/pom.xml:
<artifactId>project-ds</artifactId>
<packaging>jar</packaging>
<name>My DataSource</name>
• project/ds/src/main/resources/my-ds.xml:
<datasources>
<local-tx-datasource>
...
• project/ear/pom.xml (assuming that driver is also packaged in EAR):
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>project-ds</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>project-war</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>${jtds.driver.version}</version>
</dependency>
</dependencies>
...
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<modules>
<jarModule>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<jarModule>
<groupId>${project.groupId}</groupId>
<artifactId>project-ds</artifactId>
<unpack>true</unpack>
<uri>/</uri>
<bundleFileName>my-ds.xml</bundleFileName>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>project-war</artifactId>
<contextRoot>${context.path}</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
Will generate META-INF/application.xml:
<application>
<display-name>project-ear</display-name>
<description>...</description>
<module>
<java>jtds-1.2.4.jar</java>
</module>
<module>
<java>my-ds.xml</java>
</module>
<module>
<web>
<web-uri>project-war-1.0.0.war</web-uri>
<context-root>/</context-root>
</web>
</module>
</application>
Related
Netbeans 8.2, glassfish 5
In my maven EAR proyect, when I clean+build, it generates an EAR file. If I add this file manually to my glassfish (via glassfish console) it deploys OK and run the application.
Added glassfish to netbeans, but when click run on glassfish service, server starts, but doesnt deploy nothing. EAR file generates OK but glassfish doesnt deploy it.
My POM file in the EAR project (REMOVED SOME DEPENDENCIES AND MODULES TO SHORT IT):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>b2btravel.ear.deploy</artifactId>
<packaging>ear</packaging>
<name>B2B ear deploy</name>
<description>B2B Travel WEB-EAR deply</description>
<parent>
<groupId>b2btravel</groupId>
<artifactId>b2btravel</artifactId>
<version>1.4.11</version>
</parent>
<dependencies>
<!-- INTERNAL BUSINESS -->
<dependency>
<groupId>b2btravel</groupId>
<artifactId>b2btravel.business</artifactId>
<version>${project.version}</version>
<type>ejb</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>b2btravel</groupId>
<artifactId>b2btravel.web.bck</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>compile</scope>
</dependency>
<!-- EXTERNAL -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${maven.ear.plugin}</version>
<goals>
<goal>generate-application-xml</goal>
<goal>ear</goal>
</goals>
<configuration>
<version>7</version>
<applicationId>${application.web.id}</applicationId>
<applicationName>${application.web.name}</applicationName>
<displayName>${application.web.display.name}</displayName>
<defaultLibBundleDir>lib/</defaultLibBundleDir>
<tempFolder>${project.build.directory}/${ear.web.file.name}</tempFolder>
<workDirectory>${project.build.directory}/${ear.web.file.name}/work</workDirectory>
<skinnyWars>true</skinnyWars>
<!-- If I want maven to generate the application.xml, set this to
true -->
<generateApplicationXml>true</generateApplicationXml>
<modules>
<!-- WEB MODULES -->
<jarModule>
<groupId>b2btravel</groupId>
<artifactId>b2btravel.web</artifactId>
<bundleDir>/</bundleDir>
<bundleFileName>b2btravel.web.jar</bundleFileName>
<includeInApplicationXml>false</includeInApplicationXml>
</jarModule>
<webModule>
<groupId>b2btravel</groupId>
<artifactId>b2btravel.web.bck</artifactId>
<bundleFileName>b2btravel.web.bck.war</bundleFileName>
<contextRoot>/bck</contextRoot>
</webModule>
<ejbModule>
<groupId>b2btravel</groupId>
<artifactId>b2btravel.business</artifactId>
<bundleFileName>b2btravel.business.jar</bundleFileName>
</ejbModule>
</modules>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
<finalName>${ear.web.file.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am trying to create ear with multiple wars. Let's say i have 3 web projects with the name web1, web2, web3. These 3 web projects repositories are placed in SVN. So now i wants to create a pom.xml file which creates ear with 3 wars by accessing 3 repositories in one ear file.
I tried it by placing all modules locally using below configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<defaultJavaBundleDir>lib</defaultJavaBundleDir>
<skinnyWars>true</skinnyWars>
<archive>
<manifestEntries>
<Implementation-Description>${project.description}</Implementation-Description>
<Implementation-Vendor>Demo</Implementation-Vendor>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
<modules>
<webModule>
<groupId>com.demo.ps</groupId>
<artifactId>web1</artifactId>
<bundleFileName>web1.war</bundleFileName>
<contextRoot>/web1</contextRoot>
</webModule>
<webModule>
<groupId>com.demo.ps</groupId>
<artifactId>web1</artifactId>
<bundleFileName>web2.war</bundleFileName>
<contextRoot>/web2</contextRoot>
</webModule>
</modules>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
and under dependencies
<dependency>
<groupId>com.demo.ps</groupId>
<artifactId>web1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.demo.ps</groupId>
<artifactId>web1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.demo.ps</groupId>
<artifactId>web2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.demo.ps</groupId>
<artifactId>web2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>pom</type>
</dependency>
by using above configuration it is creating 2 individual wars inside ear file, but i want some guidance to build same by accessing both repositories remotely.
Thanks in advance !!!!
This is happening while packaging the EAR
My pom.xml is packaging the ear file where it should include projectA.jar file and projectB.war outside the /lib folder. Apparently, projectA.jar file is going inside the /lib folder which is not supposed to be. I have my application.xml which tells that these two projects should be outside the lib.
Question : how do i instruct maven not to bundle projectA.jar inside the /lib folder but to bundle it outside the /lib folder?.
My EAR structure should be:
MyWebEAR
\lib
\META-INF
projectA.jar
ProjectB.war
Below is my pom.
<dependencies>
<dependency>
<groupId>com.xxx.sms</groupId>
<artifactId>projectA</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.xxx</groupId>
<artifactId>projectB</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<earSourceDirectory>${basedir}</earSourceDirectory>
<earSourceIncludes>META-INF/*</earSourceIncludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<generateApplicationXml>false</generateApplicationXml>
<applicationXML>${basedir}/META-INF/application.xml</applicationXML>
</configuration>
</plugin>
</plugins>
<finalName>MyWebEAR</finalName>
</build>
Thanks for your time.
You need to specifically define a jarModule configuration in the modules section of your maven-ear-plugin configuration for the projectA dependency and explicitly set where you want the jar placed.
So your POM would be:
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<earSourceDirectory>${basedir}</earSourceDirectory>
<earSourceIncludes>META-INF/*</earSourceIncludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<generateApplicationXml>false</generateApplicationXml>
<applicationXML>${basedir}/META-INF/application.xml</applicationXML>
<modules>
<jarModule>
<groupId>com.xxx.sms</groupId>
<artifactId>projectA</artifactId>
<bundleDir>/</bundleDir>
</jarModule>
</modules>
</configuration>
</plugin>
The value (/) in the bundleDir tells the maven-ear-plugin to place projectA's jar in the root folder of the ear instead of the default location of lib.
You can see details on this in the plugins documentation here:
http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-module-location.html
I had the same problem in my project.
In my case, I was using an MDB so it was needed to be declared as <**ejbModule**> instead of jarModule. I also had to declare my dependency as of type ejb to be picked up Jboss (6.4):
<dependency>
<groupId>ab.cd</groupId>
<artifactId>mdb-publisher</artifactId>
<version>xxx-SNAPSHOT</version>
<type>**ejb**</type>
</dependency>
I have a maven project where i am package to EAR file and including all dependencies in /lib folder. But while deploying EAR file i am getting below 2 errors in jboss.
1)java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/jms/JMSException
For above error i learnt that i need to remove j2ee related jar files going inside the /lib folder.
2)java.lang.ClassCastException: com.xx.sms.ejb.ws.xxx.CoordinatorServiceBean cannot be cast to javax.servlet.Servlet
And this error i believe i should remove javax.servlet related jar files from /lib folder. Because this may be already provided by jboss servletContainer and you should exclude from your /lib folder.
I am new to maven world and somehow i managed to create a EAR.
Let me know how to exclude j2ee related and servlet related jar files during packing EAR.
Below is my pom.xml
<dependencies>
<dependency>
<groupId>com.xxx.sms</groupId>
<artifactId>CoordinatorBeans</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.xxx</groupId>
<artifactId>CoordinatorWeb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<earSourceDirectory>${basedir}</earSourceDirectory>
<earSourceIncludes>META-INF/*</earSourceIncludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<generateApplicationXml>false</generateApplicationXml>
<applicationXML>${basedir}/META-INF/application.xml</applicationXML>
<modules>
<jarModule>
<groupId>com.xxx.sms</groupId>
<artifactId>CoordinatorBeans</artifactId>
<bundleDir>/</bundleDir>
<bundleFileName>CoordinatorBeans.jar</bundleFileName>
</jarModule>
<webModule>
<groupId>com.xxx</groupId>
<artifactId>CoordinatorWeb</artifactId>
<bundleDir>/</bundleDir>
<bundleFileName>CoordinatorWeb.war</bundleFileName>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
<finalName>CoordinatorApp</finalName>
</build>
After adding exclusions for below dependency it worked.
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
I started using the maven ear plugin about 12 months ago and want to find out if there are any alternatives. One of the benefits of Maven is the dependency management however you seem to almost completely lost this with the ear plugin. It builds all the dependant jar's into the ear but won't actually put any of them on the classpath with out adding the configuration below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.4</version>
<configuration>
<version>6</version>
<modules>
<ejbModule>
<groupId>com.mycompany.app</groupId>
<artifactId>MyApplication-ejb</artifactId>
</ejbModule>
<jarModule>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
<jarModule>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
<jarModule>
<groupId>axis</groupId>
<artifactId>axis-wsdl4j</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
</modules>
</configuration>
</plugin>
Am I missing something does a more recent version of the plugin eliminate the need for this, is there an alternative that manages this for you? I can't believe each time I add a dependency to a module I need to add it to the ear pom configuration. The most frustrating thing is even if I remember to add a dependant library to the above configuration, if that is in turn dependent on something else (as was the case with axis) I am only finding out when I deploy the ear.
First you should have a separate module for the ear (and of course ear ) which looks like the following:
root
+-- client
! +--- pom.xml
+-- service
! +--- pom.xml
+-- ear
+--- pom.xml
Second you should update the version of the ear plugin, cause the current version is 2.6. Furthermore define your parts as dependencies
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>webgui</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>service</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
The configuration you are using is intended for supplemental 3rd party libs which should be packaged.
In addition to the answer of khmarbaise I want to note that in order for your EJB Module to be able to access the libraries you have to configure it to include the dependencies inside the META-INF/MANIFEST.MF like this:
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
...
<configuration>
...
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
...
</plugin>