16

I have a Spring Roo project and I use mvn jetty:run to run my app. The only problem is changes to the *.java classes do not hot deploy, while changes to *.jspx hot deploy fine.

So how can I configure mvn jetty to hotdeploy for java classes?

Elnur Abdurrakhimov
  • 43,663
  • 10
  • 141
  • 129
Porton
  • 8,243
  • 19
  • 73
  • 122

1 Answers1

23

You need to set the scanIntervalSeconds to a value greater than 0 to enable it:

scanIntervalSeconds - The interval in seconds to scan the webapp for changes and restart the context if necessary. Ignored if reload is enabled. Disabled by default. Default value is: 0.

So the configuration might looks like this:

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-plugin</artifactId>
  <version>6.1.22</version>
  <configuration>
    <scanIntervalSeconds>1</scanIntervalSeconds>
  </configuration>
</plugin>

Once enabled, the jetty maven plugin will scan the directory defined in classDirecory (which points to ${project.build.outputDirectory} by default i.e. target/classes) for changes.

You then just need to have your IDE compile classes in target/classes (or to run mvn compile) and Jetty will restart the context upon changes on Java classes.

Pascal Thivent
  • 535,937
  • 127
  • 1,027
  • 1,106
  • There are 404 errors while Jetty redeploys the classes. Any suggestion how to avoid them? Also see this question: http://stackoverflow.com/questions/23343243/jetty-404-error-page-on-hot-deployment – tholu May 07 '14 at 12:43
  • 1
    Unfortunately redeployment with zero downtime requires a lot of effort in the Java world :( Edit: Will try this: http://www.rafaelsteil.com/zero-downtime-deploy-script-for-jetty/ – tholu Jul 03 '14 at 13:02