Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hot deploy jsp file using tomcat7-maven-plugin?

I use tomcat7 with the tomcat-maven plugin. I am able to make it hotswap my jsp but it only work if I modify it directly in the target. How can I make tomcat also look for changes in my sources directory?

pom.xml

 <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <serverXml>${project.build.directory}/config/tomcat-config/${usingDb}/server.xml</serverXml>
                <tomcatUsers>${project.build.directory}/config/tomcat-config/tomcat-users.xml</tomcatUsers>
                <configurationDir>${project.build.directory}/config/tomcat-config</configurationDir>
                <additionalClassesDirs>
                    <classesDir>${project.basedir}/src/main/webapp</classesDir>
                </additionalClassesDirs>
                <contextReloadable>true</contextReloadable>
                <port>${tomcat.http.local.port}</port>
                <path>/${url.contextPath}</path>
            </configuration>
        </plugin>
like image 291
Marc Chery Avatar asked Jun 19 '17 18:06

Marc Chery


2 Answers

This depends on how you use/start the maven plugin. Starting it with

mvn tomcat7:run

should do the trick (in comparison to run-war or any other goal). See details at http://tomcat.apache.org/maven-plugin-2.2/tomcat7-maven-plugin/plugin-info.html

This will actually reload the context in your tomcat. I'm not sure actual "Hot replacement" without reloading the context is possible without third party libraries/plugins like jrebel or similar.

like image 159
Alejandro Alanis Avatar answered Sep 30 '22 10:09

Alejandro Alanis


You should be able to run the war:exploded maven goal to get your changes copied from your sources directory to the target directory.

like image 33
Aner Avatar answered Sep 30 '22 09:09

Aner