I am using maven2 with a struts-hibernate Java EE project and developing with myEclipse. When I run a maven build, clean&install, it generates myProject.ear under the myProject_ear\target folder as usual. However, I have to copy this ear file from that folder to the ..jboss-4.2.2.GA_2\server\default\deploy folder in order to deploy, and again turn back to eclipse and start the server.
It is because of my project has not a standard Java EE skeleton I think. However, if there is a way to tell maven to deploy my ear under the ..\deploy folder of jboss automatically, I would be glad to hear that.
If this is during development, my suggestion would be to use the WTP support and to Run [your project] on Server. And if for whatever reason you cannot use the WTP, then my second suggestion would be to use the JBoss Maven Plugin and the following goals:
jboss:hard-deploy
Deploy a file or directory to JBoss by copying files directly to the server deployment directory.jboss:hard-undeploy
Undeploy a file or directory to JBoss by removing files from the server deployment directory.
From the examples:
Deploying the files by direct copy
The plugin goals hard-deploy and hard-undeploy can be used to deploy files or directories by copying directly to the deploy directory of the server. The first step is to configure the location of the server and the file to be deployed.
<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>
The file can now be deployed and undeployed using the appropriate goals.
mvn jboss:hard-deploy mvn jboss:hard-undeploy