English 中文(简体)
Which Maven GlassFish plugin to use?
原标题:

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:

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

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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签