We ahve an enterprise application that is deployed as an EAR to clients. In this client, there is a web-app module, which our webd eveloppers would like to test without the weight of a full EAR redeployment, which (for the record) implies the following steps
Those steps are driven by maven and, due to various testing, take usually around 2mn. This is a very long delay. But, how could we reduce it for the web development ? JRebel has been tried, but it shows mixed results : most of the time it work OK, but it can also block developers under some (not ivnestigated by me) circumstances.
I have thought about allowing the war to be installed separatly from the EAR, but I guess it may introduce bigger development efforts.
Could it be possible to allow auto-redeploy of code by linking the webapp folder to Glassfish hotdeploy one ?
EDIT 1 Obviously my WAR web components do depend upon both the EJBs and some libraries of the EAR. In such a case, how can I fast-deploy/auto-deploy that WAR ?
Why do you have to re-package the war and the ear with maven each the time ? Do you work with eclipse's dynamic web projects ? (I actually don't know if it meets your requirements, and you may already know all of it well, but not enough reputation to ask for details).
GENERATE a draft WEBAPP with maven
mvn archetype:generate -DgroupId=org.yourgroup -DartifactId=MavenTestWebapp -DarchetypeArtifactId=maven-archetype-webapp
MavenTestWebapp
|
\--- JavaSources
| \MyClass.java
|
\--- War
| | ---(pom.xml)
| \ --- src
| \ --- main
| \ --- webapp
| | --- META-INF
| \ --- WEB-INF
|
\(pom.xml)
The War directory is a module of the project. I added a JavaSources directory to make it clear. I also added a pom.xml in the War directory, in order to process dependency libs from the parent project. Here is an example for the pom in the War directory :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.yourgroup</groupId>
<artifactId>MavenTestWebapp</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-war</artifactId>
<name>${project.parent.artifactId}-war</name>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<build>
<finalName>MavenTestWebapp-war</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>inplace</goal>
</goals>
</execution>
</executions>
<configuration>
<archiveClasses>true</archiveClasses>
<warSourceDirectory>${basedir}/src/main/webapp/</warSourceDirectory>
<dependentWarExcludes>
WEB-INF/classes/,META-INF/**,WEB-INF/web.xml,**/*.jar,pom.xml
</dependentWarExcludes>
<warSourceExcludes>/src/main/webapp/,target/,WEB-INF/classes/**/*.*</warSourceExcludes>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>${basedir}</directory>
<!-- the list has a default value of ** -->
<includes>
<include>pom.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
In order to gather the dependency libs, execute the mvn compile command. Then the lib directory is created in the webapp/WEB-INF directory.
MavenTestWebapp
|
\--- JavaSources
| \MyClass.java
|
\--- War
| | ---(pom.xml)
| \ --- src
| \ --- main
| \ --- webapp
| | --- META-INF
| \ --- WEB-INF
| \ --- libs
| | --- dependency-lib1.jar
| \ --- dependency-lib2.jar
|
\(pom.xml)
This is the last time we have to use maven, until we run junit tests and other features before real packaging. But for now, we should only need to compile and deploy the java classes for testing (right?). Eclipse's Dynamic Web Projects will allow fast re-deployment of java classes on glassfish.
CREATE a DYNAMIC WEB PROJECT
Create a new dynamic web project in the workspace. At the web module configuration step, set JavaSources as the Java Source Directory of this project. Set webapp as the Content Directory.
This webapp contains all the classes your web developpers have to work on, compile and deploy. It also contains a full war module with libs and compiled classes.
CREATE an EAR
Create a new Enterprise Application Project in the workspace. Add the webapp as a module for this project.
DEPLOY the EAR on glassfish
In the server view, right-click the glassfish server and add the newly created EAR containing the MavenTestWebapp web module. Each time you modify a java class, publish this EAR to your server. You can allow auto-publish, but it's usually annoying.
THANKS
If there's a better solution, if it could be improved or if it doesn't suit your project, let met know. I am not so much experienced, but I have been working with this kind of configuration before, and it may work well for fast redeployment of your java sources. Thanks, @+