There are several Maven plugins that allow to deploy web applications to various Web and JEE Containers, such as JBoss, Geronimo, WebSphere, Weblogic and others. A developer can use these plugins from the command line of from the IDE instead of relying on deployment features in tools like WTP. More over, some of those plugins allow to start and stop web application servers (for example Jetty or Cargo plugin that support multiple application servers).
If you want to start web servers from WTP, you'll need to configure server adapter as described in WTP documentation.
(TODO)
Then you can build web application project from the command line or using Maven launch configuration with m2eclipse (build, package, install).
To deploy (or start servers) with Maven you'll need to configure corresponding plugins in to pom.xml in your Web/EJB/EAR projects. Please consult Maven guides and plugins documentation for more details. Below we show several configuration examples for different application servers:
Please feel free to expand this document with your own examples.
| It is a good idea to put server configuration into the global settings.xml because then the developer can alter the configuration parameters without changing the POM files. |
Geronimo
The following example shows configuration for Geronimo Maven plugin that support goals geronimo:deploy, geronimo:undeploy, geronimo:start and geronimo:stop.
| Maven plugins provide some functionality not available from WTP. Also different plugins for different servers will have different goals (e.g. geronimo:list-modules). Please consult the plugin documentation to learn what the plugin can do. |
<build>
...
<plugin>
<groupId>org.apache.geronimo.plugins</groupId>
<artifactId>geronimo-maven-plugin</artifactId>
<configuration>
<geronimoHome>${geronimo.home}</geronimoHome>
<logOutput>true</logOutput>
<moduleArchive>${project.build.directory}/${project.build.finalName}.${project.packaging}</moduleArchive>
<assemblies>
<assembly>
<groupId>org.apache.geronimo.assemblies</groupId>
<artifactId>geronimo-jetty-j2ee</artifactId>
<version>1.2-beta</version>
<classifier>bin</classifier>
<type>zip</type>
</assembly>
</assemblies>
</configuration>
</plugin>
...
</build>
<profile>
<id>geronimo</id>
<activation>
<activeByDefault/>
</activation>
<properties>
<geronimo.home>${user.home}/Development/Servers/geronimo-1.1.1</geronimo.home>
</properties>
</profile>
JBoss
Sample configuration for JBoss Maven plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<jbossHome>${jboss.home}</jbossHome>
<serverName>${jboss.server.name}</serverName>
<hostName>${jboss.host.name}</hostName>
<port>${jboss.port}</port>
<deployUrlPath>${jboss.deploy.url}</deployUrlPath>
<undeployUrlPath>${jboss.undeploy.url}</undeployUrlPath>
<fileName>${project.build.directory}/${project.build.finalName}.${project.packaging}</fileName>
</configuration>
</plugin>
<profile>
<id>jboss</id>
<activation>
<activeByDefault/>
</activation>
<properties>
<jboss.home>${user.home}\Servers\jboss-4.0.5.GA</jboss.home>
<jboss.server.name>default</jboss.server.name>
<jboss.host.name>localhost</jboss.host.name>
<jboss.port>8080</jboss.port>
<jboss.deploy.url>
<![CDATA[
/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=
]]>
</jboss.deploy.url>
<jboss.undeploy.url>
<![CDATA[
/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=undeploy&argType=java.net.URL&arg0=
]]>
</jboss.undeploy.url>
</properties>
</profile>
Weblogic
Sample configuration for Weblogic Maven plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>2.9.0-SNAPSHOT</version>
<configuration>
<adminServerHostName>${weblogic.host.name}</adminServerHostName>
<adminServerPort>${weblogic.port}</adminServerPort>
<adminServerProtocol>${weblogic.protocol}</adminServerProtocol>
<userId>${weblogic.user}</userId>
<password>${weblogic.password}</password>
<upload>false</upload>
<remote>true</remote>
<verbose>false</verbose>
<debug>true</debug>
<targetNames>${weblogic.target}</targetNames>
</configuration>
</plugin>
<profile>
<id>weblogic</id>
<activation>
<activeByDefault/>
</activation>
<properties>
<weblogic.host.name>localhost</weblogic.host.name>
<weblogic.port>7001</weblogic.port>
<weblogic.protocol>http</weblogic.protocol>
<weblogic.user>weblogic</weblogic.user>
<weblogic.password>weblogic</weblogic.password>
<weblogic.target>cgServer</weblogic.target>
</properties>
</profile>
Comments (1)
May 02, 2008
Aleksandr Tarutin says:
While it would be nice to have plugins configured in global/user settings.xml fi...While it would be nice to have plugins configured in global/user settings.xml file, this functionality is not supported by Maven. That's why I had to define the plugins in the POM but the properties are in profiles which can reside either in the POM file or in global/user settings.xml file.