12

I'm looking for a light-weight and simple servlet container for rapid development. For example I want to write Java code without recompiling every time to see the changes in the browser. And I don't care for the servlet to be able to handle thousands of concurrent requests since I only need to install it on my local Windows machine and I will be the only one accessing it.

I'd like this sort of thing for development, so that I can upload my war to my "live" servlet container that has a more mature servlet container (Tomcat etc).

Does anything like this exist?

Luca Matteis
  • 29,161
  • 19
  • 114
  • 169

3 Answers3

11

Jetty with the Jetty Maven plugin will be your guiding light.

[EDIT]:
Original link was dead. Updated to new jetty-maven-plugin home.

WhyNotHugo
  • 9,423
  • 6
  • 62
  • 70
Jeremy
  • 22,188
  • 4
  • 68
  • 81
  • Thanks I'll try it. Can you tell me a bit more about the compilation part? Can you just change a .java file and it automatically compiles it? Or how does it work? – Luca Matteis Mar 03 '11 at 21:30
  • With the jetty maven plugin, you can configure it to scan your source directories for changes to your files. It will then pick up the change, compile it, and hot swap it into your app, or whatever you configure it to do. – Jeremy Mar 04 '11 at 00:26
  • I've configured the plugin but it doesn't seem to auto deploy when I make changes to .java files. It works find for jsps/static stuff but not for my Java files. How come? – Luca Matteis Mar 06 '11 at 20:02
  • I can't really help you with out seeing what you've done... (The jetty plugin page has a note about manual vs automatic reloading...did you read that?) – Jeremy Mar 06 '11 at 22:30
2

The most lightweight servlet container that I'm aware of is Jetty. I'm not aware of any servlet container that provides automatic reloading of classes, but you can achieve this using the JRebel IDE plugin. JRebel is not free, but it's cheap, and well worth the money.

Dónal
  • 185,044
  • 174
  • 569
  • 824
0

Yes, this is possible as you describe with Eclipse and WTP. Eclipse will rebuild your code and redeploy it to (eg) tomcat or jetty on every save. It is also possible with the maven-jetty-plugin, if you happen to be using maven.

But the overhead of shutting down the server and bringing it back up is very slight (>1s) if you use Jetty. If you are happy to do this then you have many more options available to you, like custom build scripts, maven-cargo-plugin, etc

I have recently switched away from trying to keep one long-running tomcat, to spinning up and killing dozens of instances of Jetty, and it's working fine.

Edit: Beware, though, Jetty and Tomcat have different behaviour sometimes. For example the the serving of static files via the default servlet.

Community
  • 1
  • 1
Matthew Gilliard
  • 9,298
  • 3
  • 33
  • 48