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

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.

Related

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

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.

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.

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

Maven Jetty Run from Jar

Here is want I want to do. I created a maven project and configured the jetty plugin for it in eclipse...
So from Eclipse if I do run and set the maven goal there to be jetty:run it runs my project in jetty on the port specified in web.xml. Now I want to build the jar file and when I do java -jar myapp.jar it will automatically call jetty:run.
How can I do this?
If you want to package your application so that you can hand it to someone and have them run it as a standalone application without having to go through deploying a war file into a web container, then that is a different concern from doing mvn jetty:run at development time, I will call that deployment time to avoid any confusion
At deployment time, we can't assume there will be maven on the machine, thus no mvn jetty:run, and even if there was, this would not work, unless we deliver the source code to run the build as in the development environment!
A standalone web application can be packaged by bundling the jetty jars in the application war along with a Main class to start jetty programmatically, and get it to run the application war. This relies on the fact that the file and directory structure of the WAR and JAR are different, and thus there is no significant overlap between the two, which is what makes this workaround possible, and it also leaves the option of deploying the war file in a web container possible
There is a maven plugin that embeds winstone which is another lightweight servlet container
For jetty, you may start by reading Embedded Jetty 7 webapp executable with Maven

Which way is the best to go for building a webapp as osgi bundle via maven and start them with webstart?

I am looking for a way to reach my vision. What is the best way to go?
Here is my vision:
I would like to build a captain casa app via maven (as a war file).
Then i would like to create a osgi bundle from the builded war via maven.
Next i would like build a artifact which could be downloaded and started via java webstart (jnlp).
The jnlp file should be download the osgi environment with web container support (maybe jetty osgi service), next download osgi bundled war. Then the osgi container and the jetty service should be started and my war should be deployed. Finally the app is running local in a osgi environment.
There are many questions to be answered:
How can i build a captain casa app via maven to a war?
Which maven plugin should be used to build the osgi bundle (pax, maven-bundle-plugin, tycho, ...) What are the differnce?
How to build a jnlp artifact via maven which can deployed on a site?
How must be modified the osgi bundle to support java webstart?
Known informations:
Blog entry to prepare osgi bundle for java webstart.
many pages to maven plugins, such as pax, maven-bundle-plugin, tycho, bnd, ...
It might be worth asking this as 3 separate questions, but when building Web application Bundles I use the maven-bundle-plugin version 2.2.0 (currently unreleased, so you'll need to depend on a snapshot).
Then I use the following file structure:
src/main/java - any .java files
src/main/resources - any non .java files that should be on the classpath
src/main/webapp - static content, images, html files jsps and so on
Then inside the pom once you have configured the normal data for the maven-bundle-plugin you specify the following:
<_wab>src/main/webapp</_wab>
this will cause the static content to be pulled into the bundle and the bundle to be structured with the classes and resources in the WEB-INF/classes directory.

Resources