How to deploy ear into WildFly 8.0 via eclipse IDE - eclipse

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?

Related

Creation of a java EE project on Eclipse for Java EE

I have create a Java EE project using maven.
Here is the generated hierarchy
If you observed on this image, I got an error in the index.jsp file.
When I focus in error, I got :
The superclass "jakarta.servlet.http.HttpServlet" was not found on the Java Build Path.
Error message in index.jsp
Can someone help me solve it? Thank you.
This is pom.xml file auto-generate.
<?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>tn.ipsas.jee_eclipse</groupId>
<artifactId>maven_jsf_wepp_app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>maven_jsf_wepp_app Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>maven_jsf_wepp_app</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</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>
Here is how I solved the problem.
Right click on the project, Property> Project Facets
Selecting Dynamic Web Module and I upgraded the version to 3.1
Then Apply.

Maven + Tomcat in eclipse. Tomcat return error 405

When I try deploy war app on tomcat using clean install tomcat7:deploy, it returns me 405 error from tomcat. My pom xml looks like:
<?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>org.heller.contact.app</groupId>
<artifactId>ContactsApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>ContactsApp Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<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>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>ContactsApp</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</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>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<path>/ContactsApp</path>
<!-- Set update to true to avoid exist war package can not be override
error -->
<update>true</update>
<!-- Because deploy this maven project using plugin in pom so use the
manager-script role user. -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I aslo added to my maven setting.xml
<server>
<id>localhost</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
my tomcat-users look like
<user username="admin" password="password" roles="manager-gui,manager-script" />
Can someone give me a poit how to solve this issue? I tried everything from stackoverflow, but error is still same. Application isnt deployed on tomcat yet. Thanks for help
I set ,,Use Tomcat installation" in overview of tomcat server propertie (doubleclick on Tomcat server in servers view) and it runs.

Maven install-plugin does not generate jars files for Eclipse Projects included as dependencies

I have two Eclipse Maven projects, one of them is referenced by the other project (a dynamic web project) as a dependency. When I export, using Eclipse Export menu, the web project to a war file a jar file is generated for the other project and included in the lib directory in the war file, but when using Maven directly (Run as / Maven Build... / clean install) no jar file is generated but only an empty directory with the name OtherProject.jar.
Can this be done and I am missing some thing, or is it impossible?
My web project pom.xml is:
<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>Group</groupId>
<artifactId>MyWarProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.44</version>
</dependency>
...
other dependencies
...
<dependency>
<groupId>Group</groupId>
<artifactId>OtherProject</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
My other project pom.xml is:
<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>Group</groupId>
<artifactId>OtherProject</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>src/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
...
some dependencies
...
</dependencies>
</project>

Multi module Maven Project dependency issue?

I have a multi module project where common-project is depend on another 3rdparty project and below is the pom.xml of common-project
<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.tri.iss.pet.common</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>common-um-entities</artifactId>
<name>common-um-entities</name>
<description>Common UM Entities</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<fork>true</fork>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.tri.iss.pet.common</groupId>
<artifactId>3rdparty</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
As you clearly check i have added dependency in pom.xml file but check below image its saying jar missing
Can someone tell me why only project dependency not able to load while other dependency which coming from Artifactory working fine ?
Note:- Dont be confuse from project name .

Create an "Application Client" with Maven in Java EE

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.