Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hot deploy JSP changes in maven app?

I have a maven web application. I am using springsource tool suite and its built in tc fabric server.

Every time I make any changes I have to do mvn clean install and restart the server. Even for the JSP changes.

Is there any way I can just make JSP changes and they are reflected in the browser on refresh like a regular web app (not maven app).

I have searched over internet but no success as yet.

Still No clue about it. It makes the development process extremely slow. I looked into jrebel but its not free and I am not looking for hot deploy of classes but just the hot deploy of JSP's, javascripts, css etc.

like image 437
ashishjmeshram Avatar asked Jun 02 '13 10:06

ashishjmeshram


3 Answers

I currently use a profile to copy JSPs to my target dir, which I call from Eclipse once i need the JSPs updated. You could also copy classfiles like this by adding executions.

<profile>
    <id>copyJsps</id>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <outputDirectory>${basedir}/target/app/WEB-INF/jsp</outputDirectory>
                    <resources>
                        <resource>
                            <directory>src/main/webapp/WEB-INF/jsp</directory>
                            <filtering>true</filtering>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

Use: mvn resources:copy-resources -PcopyJsps

like image 109
Dormouse Avatar answered Oct 08 '22 22:10

Dormouse


You can use Eclipse Filesync plugin to achieve this. You can configure plugin to map maven output folder to Application server directory

I know this is not maven way but it works.

Maybe this question will give some more insights.

like image 31
Vinay Lodha Avatar answered Oct 08 '22 20:10

Vinay Lodha


This is my simple solution (workaround?) while using JBoss on Linux. It should also be valid for Tomcat or any other container that supports exploaded war's.

1. Use mvn war:inplace to create an exploaded war in src/main/webapp. This will copy classes and lib there. You don't need to repeat this step if you're just changing JSP (or other /webapp/ files). Alternatively you can create symlinks to classes and lib in src/main/webapp/WEB-INF:

cd src/main/webapp/WEB-INF
ln -s ../../../../target/classes
mvn package
ln -s ../../../../target/*/WEB-INF/lib

2. In the deployment directory create a symlink to src/main/webapp:

cd $DEPLOYMEN_DIR
ln -s $MYAPP_DIR/src/main/webapp myapp.war

This makes changes to JSP and other webapp files instantly available. If you want to see the changes in your classes then you can trigger a reload of the application only my modifying web.xml. On you can run this script to monitor trigger the restart:

#!/bin/bash
while sleep 1; do 
    if [[ -n $(find WEB-INF/classes -newer WEB-INF/web.xml -type f) ]];then
        date
        touch WEB-INF/web.xml
    fi
done

Run it from the src/main/webapp/ directory.

Note on JBoss AS 7: Here to trigger a reload you need to create a myapp.war.dodeploy file instead of touching web.xml

like image 1
rzymek Avatar answered Oct 08 '22 21:10

rzymek