I've been trying to integrate deploying java .war's in GlassFish V3 through Maven. While I have found a few plugins, none of them look to be very active:
Maven Glassfish Plugin
Eskato's Wordpress Blog on Maven
And I got the most information out of Eskato's Blog, it was written March 2008, so I don't know what the state of GlassFish Maven integration is, nor can I find a suitable plugin to work with. With the Maven GlassFish Plugin I have had some success, but it still doesn't work entirely well for all goals it says it supports, which makes some of the commands ineffective.
Has anyone else been able to integrate Glassfish V3 and Maven successfully? If so, what resources did you use to get it done?
Update: CARGO-491 has been fixed and I've updated my answer accordingly. To summarize, there are now basically three options:
Maven GlassFish Plugin
A first option would be to use the Maven GlassFish Plugin. This plugin allows to interact with a local or remote GlassFish install and the management of Glassfish domains and component deployments from within the Maven build lifecycle.
Maven Embedded GlassFish Plugin
The second option would be to use the Maven Embedded Glassfish Plugin. As stated by its name, this plugin doesn't rely on an existing install but uses an embedded GlassFish, running in the same JVM as the plugin. This plugin is extremely nice if you want to keep your build portable (anybody can get your POM and run a build involving GlassFish without having it installed) with almost the same features as a normal GlassFish install, except clustering of course (you can use a preconfigured domain.xml if you want). See Testing with the GlassFish Maven plugin and JavaDB Embedded for an example.
Maven Cargo Plugin
The work initiated by Kohsuke Kawagushi as been finally integrated in Cargo and, starting with Cargo 1.0.1, GlassFish 3.x is now supported. Using the Maven Cargo plugin is thus a third option. This would be interesting for builds that want to interact with containers in an agnostic way. But I'm not sure Cargo allows all the flexibility of the GlassFish specific plugin(s) (e.g. deployment of JMS resources, etc).
maven-glassfish-plugin and maven-embedded-glassfish-plugin both have their pros and cons. The main difference is that the latter works with an Embedded Glassfish instance, as indicated by its name, i.e. the server is running in the same VM as the plugin.
So you cannot use maven-embedded-glassfish-plugin to deploy your WAR to a standalone Glassfish server, you need maven-glassfish-plugin to do that.
The main problem I had with the maven-glassfish-plugin is the fact that its interaction with the Glassfish server is stateful - I could not find a way to use it such that my WAR would get deployed to the server in any case, no matter whether the previous build succeeded or not.
glassfish:deploy does not work if the WAR is deployed already. glassfish:redeploy does not work if the WAR is not deployed. And Maven has no if-else logic...
I've blogged about how to configure Maven Embedded GlassFish plugin to work correctly with GlassFish 4.0 until there's a new release of that plugin.
https://blogs.oracle.com/brunoborges/entry/glassfish_4_beta_and_maven
Also, it is possible to configure a datasource in the glassfish-resources.xml and have it working correctly.
https://blogs.oracle.com/brunoborges/entry/configure_datasources_for_maven_embedded
These are useful tips to anyone that want to run Java EE 7 projects with Maven and GlassFish 4
You can use this one :
http://www.hascode.com/2011/09/java-ee-6-development-using-the-maven-embedded-glassfish-plugin/
https://github.com/andrzejsliwa/glassfish-maven-plugin/wiki
http://cargo.codehaus.org/Maven2+plugin
I use the glassfish plugin on maven-glassfish-plugin.dev.java.net and did some code changes to support v3 now. I requested committer status and wait for acknowledgement. Hopefully I can commit my changes.
Related
we recently migrated to Maven Build manager & git hub repository for our Java web-app. Also i switched to eclipse as eclipse has good set of plugins.
As a new bie, i am simply running mvn clean package from terminal at the code root directory. And then moving the compiled code i.e., /target/SNAPSHOT/* to tomcat/webapps/ROOT location.
And then starting Tomcat7 server. The process is time taking especially when i do code changes in Java & configuration .xml files.
I want to do it completely in IDE environment as i did earlier in Netbeans, update code -> build and run in debug mode, -> do code changes and then commit.
Heard of egit & m2e in eclipse for maven & github integration, but not sure how to use it.
Please walk me through the steps required in doing so. I am completely new to eclipse.
--
Thanks
You might want to consider using maven-jetty-plugin http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin for running the webapp. You will not need to copy over stuff to tomcat. After configuring this plugin, you can simply run your application by doing mvn jetty:run
I generally do not like running webapps inside Eclipse. It's a personal prefrence, but it is always nice to have an IDE neutral way of building and running your applications. If you have m2e things should work simply fine. I have seen maven-jetty-plugin having hot pluggability where if you changed your web.xml, jetty would reload your application.
We use Git for version control and Maven for dependency management and build automation. Once your project has successfully imported into Eclipse and recognized as a valid java web project, you don't need either Git or Maven in order to build/run it inside IDE. Just creat a server using you existing tomcat installation, add the project to server, then select Run as > Run on Server.
The Complete Guide:
Creating a server
Adding projects to a server
Starting a server
For more details, check out Testing and publishing on your server.
See title. I would also like the project to redeploy after every change. I am new to this area so my knowledge isnt that good. I tried googling and searching here, but I can't find any answer.
thanks for any help
There are two plugins that combined together in Eclipse work quite well together to perform what you want:
M2E: M2Eclipse which handles everything related to Maven.
Eclipse Web Tool Platform (WTP): which handles everything Java EE related (Tomcat, JBoss, etc...)
For M2E to work properly with WTP, you need to add m2e-wtp. You may find several useful information as well as some good links here.
I would start from the Eclipse Java EE distribution (it includes already Eclipse-WTP) and then add M2E (either with their update site or through eclipse market place: look for M2E and M2E-WTP).
From there, you create a Web Project and you can run it on a Tomcat server. The first time you try to run you project on a server, you will install Tomcat and it will appear in view named "Server". Double click on the server to configure ports, automatic deployment etc...
You can easily deploy a webapp using the Cargo Tomcat plugin. Here's helpful articles on this topic:
Maven Tomcat Deployment using Cargo plugin.
Autodeployment with Maven, Tomcat, and Cargo.
For a GWT application which I build with the GWT Maven Plugin (gwt-maven-plugin), I can run the GWT Development environment with
mvn compile war:exploded gwt:run
and then launch a browser. This requires that the browser provides the GWT Developer Plugin. (Firefox 6 for example does not yet support the GWT Plugin).
Does the GWT Maven Plugin also allow to simply run the included Jetty container with the GWT application, without a development mode?
After configuring gwt-maven plugin you could simply run the following.
mvn jetty:run-war
After gwt compilation the resulting war will be placed in jetty and started via Maven Jetty Plugin.
The only way to run the project without plugin is to compile it and run on a server. If you are using Netbeans just hit run. The IDE will compile and deploy project on a server. In other way just compile it with the following command (you can omit tests and reports):
mvn clean:clean resources:resources compiler:compile war:exploded resources:testResources compiler:testCompile surefire:test gwt:compile war:war
After this you 've got ready to deploy war file. To deploy it to the Glassfish there are now basically three options:
Maven GlassFish Plugin
A first option would be to use the Maven GlassFish Plugin. This plugin allows to interact with a local or remote GlassFish install and the management of Glassfish domains and component deployments from within the Maven build lifecycle.
Maven Embedded GlassFish Plugin
The second option would be to use the Maven Embedded Glassfish Plugin. As stated by its name, this plugin doesn't rely on an existing install but uses an embedded GlassFish, running in the same JVM as the plugin. This plugin is extremely nice if you want to keep your build portable (anybody can get your POM and run a build involving GlassFish without having it installed) with almost the same features as a normal GlassFish install, except clustering of course (you can use a preconfigured domain.xml if you want). See Testing with the GlassFish Maven plugin and JavaDB Embedded for an example.
Maven Cargo Plugin
The work initiated by Kohsuke Kawagushi as been finally integrated in Cargo and, starting with Cargo 1.0.1, GlassFish 3.x is now supported. Using the Maven Cargo plugin is thus a third option. This would be interesting for builds that want to interact with containers in an agnostic way. But I'm not sure Cargo allows all the flexibility of the GlassFish specific plugin(s) (e.g. deployment of JMS resources, etc).
My problem is with respect to debugging web application on an already installed glassfish using eclipse.
If I create a web project using eclipse then eclipse will let be deploy and debug application on an already installed glassfish application server. However, if I have created a web project using maven archetype, eclipse does not let me debug the application.
I can use maven's jetty or tomcat plugin and debug the application but I need to debug application on an already installed glassfish. Basically I have followings
1) Web application created using maven archetype
2) Eclipse IDE
3) Glassfish which is already installed outside of Eclipse IDE
I came across maven's glassfish plugin but as far as I understood it is not for debugging the application.
Please let me know your suggestions.
Thanks
If I create a web project using eclipse then eclipse will let be deploy and debug application on an already installed glassfish application server. However, if I have created a web project using maven archetype, eclipse does not let me debug the application.
This is not true. Whether you use the Maven Eclipse Plugin (which provides WTP support) or m2eclipse (with the optional Maven Integration for WTP installed from the m2eclipse Extras), you can deploy a project created outside Eclipse to an existing "Server" (that you can start in Debug mode), as long as you imported it appropriately (Import... > Existing Project into Workspace if you use the former, Import... > Maven Projects if you use the later).
Basically I have followings 1) Web application created using maven archetype 2) Eclipse IDE 3) Glassfish which is already installed outside of Eclipse IDE
I use the same setup with several projects with no problem (and can debug them on my locally installed GlassFish server).
I came across maven's glassfish plugin but as far as I understood it is not for debugging the application.
There is no need for extra Maven plugins, you can just rely on your IDE if you follow the right steps.
I don't know about eclipse, but IntelliJ IDEA has a remote debug feature. You start your server with something like
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5055
and then the IDE will connect to that port and you'll have a regular debug.
I'm sure eclipse has this feature.
EDIT: This article shows how to use this feature with eclipse.
I´m going to write it most for me in order to keep trace of my solution:
If you are using the maven.failsafe plugin just force the execution of glassfish internally the current JVM started by maven avoiding the fork with the parameter
-DforkCount=0
in such way you are able to debug both test and server from the usual way, ie. running a debug task from eclipse and setting break points both in test and in server side.
Extra parameter information could be found here, including setting different debug port:
http://maven.apache.org/surefire/maven-failsafe-plugin/examples/debugging.html
I have to organize a development environment where I can run Maven projects with JBoss Seam, IDE eclipse 3.4.x and deploying to JBoss 5.
The projects that will run on this environment are based in Java 6, EJB3 and JSF1.2. The environment has to support hot-deploy.
I used to work in a development environment with Sysdeo Plugin to make Tomcat run all my applications - I've rarely used EJB (only for MDB's).
So I would prefer an environment similar to this.
I'd like to know what you guys use for the kind of architecture (what kind of eclipse plugins - if they work fine, things like that)
The thing I really didn't get right is why my Maven2 project with SEAM as a dependency packaged as EAR doesn't appear in my server (in Eclipse Ganymede - tab servers) for me to make deploy (right click - option Add and Remove Projects...).
Do I have to include an specific project nature to make my Maven2 EAR project visible to my JBoss AS included in my Eclipse Ganymede?
Seam doesn't appear to go well with Maven2. I'm facing some problems to make they work together - some dependencies appear to be missing and I have to put some extra files in some special places like seam.properties and components.xml with some special contents.
I feel like forced to use seam-gen and Ant. Too bad!
Not sure if this is helpful to you, but but we run the following
eclipse as IDE
mercurial for source code management
merclipse mercurial eclipse plugin http://goldenhammers.com/merclipse/
maven for builds (and m2eclipse)
mylyn with bugzilla for issue tracking
tomcat as application server
hudson for continuous integration http://hudson-ci.org/
reviewboard for code reviews http://www.review-board.org/
sonar for code quality metrics http://sonar.codehaus.org/
proxmox VE for virtualization http://pve.proxmox.com/wiki/Main_Page
Most things run on separate virtual machines to keep interference to a minimum. Proxmox VE is a breeze to setup (15 mins and you are running).
Hudson monitors the repository and automatically builds and tests each push.
If the war build is successful it is automatically (re)deployed (using a hudson plugin) into Tomcat and restarted.
I cannot recommend these tools enough.
HTH
I am currently working on the same environment you asked for, with the only difference I am running the app on a tomcat 6.0.18. I prefer to use tomcat 'cause it's so faster to run, and I don't use EJB for now.
Eclipse plugins :
maven : m2eclipse.codehaus.org
jboss tools : www.jboss.org/tools
web tools platform for hot deploying : www.eclipse.org/webtools/
I took the Eclipse Java EE version, I don't use seam-gen to create the basic architecture.
I don't have so many problems with this environment, sometimes the hot-deploy doesn't work and I have to manually clean files.
The only problem I had was with the separation of my app in two modules : eclipse wasn't doing the job well (not taking the last package of one module while building the other one), and I discover the option "disable workspace resolution", which works fine now.
Works fine. Hope it will for you.