Create an "Application Client" with Maven in Java EE - netbeans

I am trying to create a maven based Enterprise Application with an Application Client which runs in the Application Client Container from GlassFish. It should fit togheter as the Project template from Netbeans "Enterprise Application" + "Enterprise Application Client" but with maven and not ant.
Until now I have following projects
Assembly Maven Project
EAR-Module
EJB-Module
WEB-Module (works well with inside the ear)
Swing Client Module
The Assembly pom.xml looks like:
<project xml...
<modules>
<module>shop-ear</module>
<module>shop-web</module>
<module>shop-ejb</module>
<module>shop-client</module>
</modules>
</project>
The ear pom.xml contain
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>shop</artifactId>
<groupId>my.package.name</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>ch.hslu.edu.enapp</groupId>
<artifactId>shop-ear</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<!-- ... -->
<dependencies>
<dependency>
<groupId>my.package.name</groupId>
<artifactId>shop-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>my.package.name</groupId>
<artifactId>shop-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>my.package.name</groupId>
<artifactId>shop-client</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
And the Swing Client pom.xml contains
<project xmlns=....>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>shop</artifactId>
<groupId>my.package.name</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>my.package.name</groupId>
<artifactId>shop-client</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>shop-client</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<mainClass>my.package.name.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<url>http://download.java.net/maven/2/</url>
<id>java.net</id>
<layout>default</layout>
<name>java.net</name>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jdesktop</groupId>
<artifactId>beansbinding</artifactId>
<version>1.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Currently I have no dependencies between the Swing Client and the EJB Module. I just want to get a simple Swing form up and running out of the ACC form GlassFish (v 3.1.1).
But this doesn't work. The Swing-Client is packed into the lib folder inside the ear-file and I can not start it.
Do you know a tutorial or example which fulfill this task?

Your ear pom needs to configure the ear plugin like (maybe you just left it out when you put it into your question?):
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<version>6</version>
<generateApplicationXml>true</generateApplicationXml>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>com.foo</groupId>
<artifactId>shop-web</artifactId>
<contextRoot>webstuff</contextRoot>
</webModule>
<ejbModule>
<groupId>com.foo</groupId>
<artifactId>shop-ejb</artifactId>
<classifier>single</classifier>
<bundleFileName>shop-ejb.jar</bundleFileName>
</ejbModule>
<jarModule>
<groupId>com.foo</groupId>
<artifactId>shop-client</artifactId>
<bundleDir>/</bundleDir>
<bundleFileName>shop-client.jar</bundleFileName>
<includeInApplicationXml>true</includeInApplicationXml> <!-- i don't remember if this was absolutely necessary -->
</jarModule>
</modules>
</configuration>
</plugin>
That will package your application client jar outside the lib folder, and will help you define the context roots for your war modules (there isn't another way that I could find). The bundleFileName was important to get the URL to launch the client to make more sense.
I don't know of a single tutorial that puts this all together, but some resources are:
http://blogs.steeplesoft.com/2011/02/java-ees-buried-treasure-the-application-client-container/
http://java.sun.com/developer/technicalArticles/J2EE/jws-glassfish/part3.html
http://blogs.oracle.com/quinn/entry/customizing_generated_java_web_start

Now, there is official maven support for app clients
http://maven.apache.org/plugins/maven-acr-plugin/
http://maven.apache.org/plugins/maven-ear-plugin/examples/using-app-client.html
http://web.anahata-it.com/2011/09/09/java-jee-desktop-maven-enterprise-application-client/
NetBeans 7.1 will add support for maven app clients too.

Related

Problems building effective model for com.MyProject:jar:1.0-SNAPSHOT

My project already runs correctly inside netbeans, but when I want to do "clean and compile" to create the .jar file, it doesn't create the "dist" folder but a "target" folder and doesn't even execute the file, in Console I get It shows some meven errors and the pom file that I still don't know how to fix. I hope someone can guide me in this final step of my project. I leave the capture and the code of the pom file.
error 1
error 2
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.mycompany</groupId>
<artifactId>Compugar1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<showDeprecation>false</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>unknown-jars-temp-repo</id>
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf-intellij-themes</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>AbsoluteLayout</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>config/sun_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
<name>Compugar</name>
<description>Base de datos de clientes, antenas, reportes y pagos</description>
</project>
I tried to delete the dependencies and download them again, but it didn't work...

eclipse 2018-09 maven can't find dependency but it exists everywhere

I'm using an older version of eclipse 2018-09 with 32-bit Java, not sure that makes a difference. (project limitation for using these older versions)
I have been using the default maven plugin with the project and it all has worked so far, except for the following one:
<!-- https://mvnrepository.com/artifact/com.github.kilianB/JImageHash -->
<dependency>
<groupId>com.github.kilianB</groupId>
<artifactId>JImageHash</artifactId>
<version>3.0.0</version>
</dependency>
https://mvnrepository.com/artifact/com.github.kilianB/JImageHash/3.0.0
I get:
Missing artifact com.github.kilianB:JImageHash:jar:3.0.0
I have done all the maven things, clean, install, etc...
This jar is located at "JCenter repository (https://jcenter.bintray.com/)".
And the url and files are all there.
https://bintray.com/kilianb/maven/JImageHash/3.0.0#files/com%2Fgithub%2FkilianB%2FJImageHash%2F3.0.0
I even downloaded the files and jars.
I have no settings.xml in my .m2, as I'm using the default eclipse maven. The pom.xml is the default one and I added the dependencies I have needed.
What's missing?
Thanks in advance.
FWIW here's my pom I'm using
<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>
<groupId>patmangames</groupId>
<artifactId>carddetect</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>4.5.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>4.3.0-1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.0</version>
</dependency>
<!-- FAILS TO FIND AND DOWNLOAD-->
<dependency>
<groupId>com.github.kilianB</groupId>
<artifactId>JImageHash</artifactId>
<version>3.0.0</version>
</dependency>
<!-- FAILS TO FIND AND DOWNLOAD-->
</dependencies>
</project>
Without a settings.xml you only get jars from MavenCentral.
Note that MavenCentral has nothing to do with mvnrepository. Finding a jar on mvnrepository does not mean that it is in MavenCentral.
Indeed, in your case, the jar is in jcenter, so you need to write a settings.xml where you add that repository as <repository>.

Deployment assembly of a Maven's Springboot project in Eclipse

Trying to deploy a SpringBoot Maven project on my Tomcat in Eclipse.
First problem: the lib directory is empty after deployment, Maven is not doing the job although the dependencies are in the Build Path.
First solution: i added manually my Maven's dependencies to the deployment structure in Property > Deployment Assembly, and this worked fine.
Second problem: each and everytime i update my Maven's project, the Deployment Assembly goes back to the original state (no Maven's dependencies in WAR) and again i have to do the job manually.
Tried everything i could, everything i've found here, still not working.
My pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>***</groupId>
<artifactId>***</artifactId>
<version>***</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>***</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
My Eclipse Maven plugin installation just in case:
Found the answer here.
I did not have m2e-wtp plugin installed, this fixed my problem.

SEVERE: Servlet /JAXRS-HelloWorld threw load() exception java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

I read through plenty of posts related to this issue but couldn't get any help .
ERROR
Appreciate if someone can help me out.
enter image description here
This is how my POM and web looks like . I have tried copying the required war file to C:\appache tomcat 7 but no luck. Even deploying it within the eclipse also gives me the same error.
WEb
enter image description here
POM.xML:-
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tutorialacademy.rest</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworld Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
By the exception, it looks like the com.sun.jersey.spi.container.servlet.ServletContainer class is not available in your classpath.
Note that Jersey 1.x and Jersey 2.x use different package names:
Jersey 1.x: com.sun.jersey
Jersey 2.x: org.glassfish.jersey
So, I understand you are using Jersey 1.x.
Jersey 1.x depencency
To use Jersey 1.x, you need the following dependecy in your pom.xml:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
To read more about Jersey 1.x dependencies, have a look at the documentation.
You can check the latest version of the jersey-server artifactId in the Maven Repository.
Jersey 2.x depencency
If you want to use Jersey 2.x, you have to add the following dependency to your pom.xml:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0,
use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
</dependency>
You can check the latest version of the jersey-container-servlet artifactId in the Maven Repository.
Read more about Jersey 2.x dependencies in the documentation.
UPDATE
If you can, I do recommend using Jersey 2.x rather than Jersey 1.x.
To do it, use the following pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tutorialacademy.rest</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Hello World</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0,
use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And the following web.xml:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>
If you are trying to make a Web application to provide web service using Jersey library in Tomcat and Eclipse and still getting problem after adding jersey-server.jar in the classpath. You can follow these steps to add dependency on deployment assembly.
Project -> properties -> development assembly -> add -> java build path entries -> maven dependency
This should work.

How to deploy ear into WildFly 8.0 via eclipse IDE

I have installed the JBoss AS tools in my eclipse. Then I have created an WildFly 8.0 server. I have parent project pom.xml like below:
<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>
<groupId>com.company</groupId>
<artifactId>trx-server-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.7</java-version>
<javaee-api-version>7.0</javaee-api-version>
</properties>
<modules>
<module>trx-server-ear</module>
<module>trx-server-domain</module>
<module>trx-server-services</module>
<module>trx-server-web</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<!-- compiler plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.4</version>
<configuration>
<ejbVersion>3.2</ejbVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
And ear project pom.xml is like:
<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>
<parent>
<groupId>com.company</groupId>
<artifactId>trx-server-parent</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>trx-server-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com.company</groupId>
<artifactId>trx-server-web</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.company</groupId>
<artifactId>trx-server-services</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
<build>
<finalName>trx-server</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<finalName>trx-server</finalName>
<version>7</version>
<defaultJavaBundleDir>lib/</defaultJavaBundleDir>
<modules>
<webModule>
<groupId>com.company</groupId>
<artifactId>trx-server-web</artifactId>
<contextRoot>/trx-server-web</contextRoot>
</webModule>
<ejbModule>
<groupId>com.company</groupId>
<artifactId>trx-server-services</artifactId>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
I defined the trx-server-domain module as jar file and packaged into the lib folder. When run mvn clean install on my parent pom.xml, I got an ear file named trx-server.ear. Then the trx-server.ear file structure is like:
-- trx-server
-- lib
-- trx-server-domain-1.0.0.jar
-- trx-server-services-1.0.0.jar
-- trx-server-web-1.0.0.war
I can deploy this ear file to WildFly server manually (via web management page). Everything is fine for that.
My problem is when I deploy some changes via Eclipse, I mean via the server adapter. The root web contextRoot is not what I defined in the ear project pom.xml file. And the trx-server-domain will be deploy as EJB which should be a jar file under lib folder.
I got a trx-server-ear.ear folder in the WildFly deployments directory which is not what I wanted. The structures of this folder is:
trx-server-ear.ear
-- trx-server-domain-1.0.0.jar
-- trx-server-services-1.0.0.jar
-- trx-server-web-1.0.0.war
No lib folder and all jar/war files are in same level.
The problem only exist when I deploy the ear in the Eclipse. Is there any other plungin I should install?
Anyone could give me example of how to configure the ear with multiple modules?