Jelastic - deploy from maven generates both WAR and EAR files and fails - maven

I am using Jelastic and I have an environment with a WildFly 10.1 node and a Maven 3.5.0 node. When I click "build and deploy" on the project in the Maven node my application should build and deploy a EAR file.
However, after the first time I do that, the deploy fails, and when I check the WildFly admin console there is a EAR and a WAR file. I have no idea where this WAR is coming from, and I can't find such file in the "target" folder either.
Checking the WildFly log, I see a "org.jboss.msc.service.DuplicateServiceException: Service jboss.naming.context.java.app.myapp-dev is already registered"
If I remove the war from the admin console, disable the EAR and re-enable it, the application works.
I don't know exactly how Jelastic works with maven, but I believe there is no problem with my pom.xml files.
Thanks in advance!
edit: here's the pom.xml for the project root, and the pom.xml for the inner EAR module.

Automatic build and deploy functionality in Jelastic is designed to build all the targets specified in pom.xml and deploy all the built artifacts to the app server.
If multiple targets are specified in root pom.xml of the project, all of them will be built and deployed to the app server, not only the .ear target.
Please try to deploy the subproject with the inner EAR module with the appropriate pom.xml as root project file to build and deploy only the *.ear file.

Related

Maven simple archetype for ejb (without web app and servlets)

I am looking for a simple archetype for EJB with working example.
I want build a single EAR file with pure EJBs (Servlet and WebApp are not required)
I have used this maven-archetype-j2ee-simple archetype and deleted servlets and projects primary-source and src folders.
I am able to build, but I am not able to deploy in to GlassFish, when I run the command mvn glassfish:deploy it is always looking for .war file inside the target folder.

Maven JBOSS application deployment

I followed this tutorial http://www.mastertheboss.com/jboss-maven/jboss-maven-example-building-a-java-ee-6-application/ in order to have a simple web application to better understand Java EE and JBOSS. I set up the example project (by archetype) and compiled it.
However, I am stuck after running mvn compile. I want to deploy my application as a war file to my JBOSS webroot directory (in my case /usr/share/jboss-as/standalone/deployments/).
I think mvn package and mvn install must be executed. Where can I specify that I want a war file and that it should be copied to my deployment location on JBOSS?
Obviously, I can use the jboss maven plugin http://docs.jboss.org/jbossas/7/plugins/maven/latest/, which is addressed via console
jboss-as:deploy
Configuration is read from the POM file.

deploying multple war files using intelliJ IDEA

I have a maven based spring mvc project. I can build that project and run it via tomcat manually like this
mvn package -Dbuild.name=App1
mvn package -Dbuild.name=App2
mvn package -Dbuild.name=App3
and then can copy those generate war files App1.war, App2.war and App3.war into my tomcat folder and start it. It works fine.
Question is how to do the same using intelliJ IDEA?
I generated war files one by one by using Maven Project window and creating custom value for package goal. It generates .war files in target folder. But when I run it in Tomcat of intelliJ it only runs the application at root "/" address. For other addresses
/App2 -> 404
/App3 -> 404
You can have multiple artifacts created in IntelliJ IDEA and configured for deployment at the same time in the application server Run/Debug configuration, Deployment tab under different contexts.
Note that Deployment tab has a configuration to perform the deployment from the External source where you can specify the location of the war produced by Maven if you don't want to use artifacts for some reason.

How do I deploy a maven created webapp to tomcat

So I was following http://www.mkyong.com/jsf2/jsf-2-0-hello-world-example/ for a simple tutorial on how to use maven and jsf. I created a maven project by running mvn archetype:generate -Dfilter=org.apache:maven-archetype-webapp in my command prompt. Then I continued with the tutorial, I wound up creating all necessary files, but then when I got to the end, I realized I did have a server created. So I created one real quick, but when it came to the point of adding files to the server (from the add or remove dialog box), no projects or files showed up. I am not on my computer where the project is located so I can't copy/paste the .pom file in, but it looks practically exactly like the pom in the tutorial (only difference is groupId, artifact, ect.) No additional plugins, dependencies, or configs.
Do you want to deploy the webapp within Eclipse to Tomcat? Or as some sort of automatic/continuous deployment?
Within Eclipse you often need to add the Dynamic Web project and JSF facets to your project so Eclipse recognizes the project as deployment capable. If you are using m2eclipse make sure to install the m2eclipse wtp add on so this is done automatically.
If you want to add auto-deployment to the pom.xml I recommend using the maven cargo plugin: http://cargo.codehaus.org/Maven2+plugin - it supports the major containers.
For tomcat you need to modify the tomcat-users.xml to allow auto-deployment and leave the tomcat-manager application in place. If you have startet tomcat and pointing your browser to http://localhost:8080/manager/html/list it should either tell you to login or what to add to that file.
The configured user is then used in the configuration to deploy the war file via the tomcat-manager using the mvn cargo:deploy goal. The configuration has to be added to the pom.xml using war as packaging, not to the parent-pom.xml

Deploy MavenWebApp in Eclipse Tomcat

I have the following Problem:
I have a Maven MainProject with some SubProjects.
Two of this SubProjects are WebApplications. (One WebApp and one WebService)
If I build the MainProject in the command line with mvn clean package the 2 .war files are deployable in an external Apache Tomcat 6.0.
If I build the MainProject in eclipse with the m2e plugin i can also deploy the .war files into an external Tomcat.
BUT if i want to deploy the WebProjects in an Apache Tomcat in Eclipse, it doesn't boot.
The Problem is, that the file structure of the eclipse build for the internal Tomcat is different to the Maven one.
In the Maven build (console / m2e) the path is correctly from e.g. Project/src/main/java/com/... to WEB-INF/com...
The eclipse build for the internal Tomcat creates the structure like WEB-INF/main/java/com/...
So many of the .xml files which are mandatory for the Tomcat boot are not found bacause of the wrong path.
How can i tell eclipse that it should do the similar build like m2e or maven on command line so that i can use an internal tomcat in eclipse?
I am using
Eclipse Juno 4.2 or Helios 3.6
m2e - Maven Integration for Eclipse / 1.1.0.20120530-0009 / org.eclipse.m2e.feature.feature.group
Maven Integration for WTP / 0.15.2.20120306-2040 / org.maven.ide.eclipse.wtp.feature.feature.group
I fixed the problem.
The problem was the deployment assembly options in the eclipse projects.
Eclipse default option is to deploy /src to / folder.
Because of the maven structure /src/main/java/com the deployed folder also looks like /main/java/com.
I only had to change the source folder from /src to /src/main/java (the destination still remains /). If there are other necessary files i had to add them the same way, e.g. /src/main/resources.
The /src/main/webapp folder was already set correctly by eclipse to /WEB-INF

Resources