Tomcat Maven Plugin and Maven Multi-Module Projects

We have an application that until recently was one Maven WAR project. We used the Tomcat Maven plugin to run the application on local developer workstations using:

mvn tomcat:run 

We were able to modify the JSP files while the running instance of Tomcat is running, and the changes will be displayed in web browsers in order. I understand (from the plugin documentation) that when using the tomcat: run target, the WAR loads as a dynamic web application, and therefore, changes made to the JSP files in the initial state are collected by Tomcat at runtime without rebooting.

The application reached a fairly large size, and we needed to reuse a large number of classes in several different places besides the web project, so we reorganized the code base into a multi-module Maven project. Now the structure:

 parent Maven POM | ---- artifact1.jar | ---- artifact2.jar -> depends on artifact1.jar | ---- artifact3.jar -> depends on artifact1.jar | ---- artifact4.jar -> depends on artifact2.jar and artifact3.jar | ---- artifact5.war -> depends on artifact1.jar, artifact2.jar, artifact3.jar and artifact4.jar 

After refactoring, we were not able to use tomcat: start from the project root directory to start the WAR project, because the plugin could not detect JAR artifacts. So, we switched to using the tomcat: run-war-only plugin. The WAR module is now ready for use.

However, from the documentation, it seems that the war-only target sees WAR files as packaged web applications. Therefore, any changes that we make in JSP files are no longer loaded by the Tomcat built-in server during operation. For every change in the JSP files, we must restart the server.

Is there any way for us in this multi-module Maven configured to run WAR projects as dynamic web applications, so that at least Tomcat changes JSP files are collected without rebooting?

+7
source share
2 answers

Install mvn first and then

 mvn -pl artifact5 tomcat:run 
+3
source

First, use the new version of the tomcat plugin, which is now located in Apache, see http://tomcat.apache.org/maven-plugin-2.0/ .

Then, if you use maven3, you just use tomcat6 / tomcat7: run from above. All classes from the modules will be added to your webapp class loader (it will save some ios, since you do not need to install all banks first). http://tomcat.apache.org/maven-plugin-2.0/run-mojo-features.html

NTN!

+3
source

All Articles