How to enable maven to deploy ear in application. server automatically

I am using maven2 with a Java EE project with struts-hibernate support and developing with myEclipse. When I run maven build, clean & install, it generates myProject.ear in the myProject_ear \ target folder, as usual. However, I have to copy this ear file from this folder to the folder ..jboss-4.2.2.GA_2 \ server \ default \ deploy in order to deploy, and again go back to eclipse and start the server.

This is because my project does not have a standard Java EE skeleton, I think. However, if there is a way to tell maven to deploy my ear in the .. \ deploy jboss folder automatically, I would be happy to hear that.

+4
source share
1 answer

If this is during development, my suggestion would be to use WTP support and Run [your project] on the server . And if for some reason you cannot use WTP, then my second suggestion would be to use the JBoss Maven Plugin and the following goals:

  • jboss:hard-deploy
    Deploy the file or directory to JBoss by copying the files directly to the deployment directory server.
  • jboss:hard-undeploy
    Undeploy a file or directory for JBoss by deleting files from the deployment directory server.

From the examples:

Deploy files using direct copy

The goals of the plugin are hard-wired and hard-undeploy can be used to deploy files or directories by copying directly to the serverโ€™s deployment directory. The first step is to configure the server location and file for deployment.

 <project> ... <build> ... <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jboss-maven-plugin</artifactId> <version>1.4.1</version> <configuration> <jbossHome>/usr/jboss-4.2.3.GA</jbossHome> <serverName>all</serverName> <fileName>target/my-project.war</fileName> </configuration> </plugin> ... </plugins> ... </build> ... </project> 

Now the file can be deployed without work using the appropriate purpose.

 mvn jboss:hard-deploy mvn jboss:hard-undeploy 
+7
source

All Articles