48

What are the benefits of embedding jetty vs deploying your webapp(s) in jetty? If you are planning on deploying more than one web app, should you strictly stick with deploying a war file for each web app (as opposed to writing an embedded server which calls each web app)?

starblue
  • 55,348
  • 14
  • 97
  • 151
Michael Balint
  • 2,255
  • 4
  • 25
  • 27
  • 5
    I'd like to keep the embedded tag here, searching for "jetty embedded" is what people do. – Pascal Thivent Apr 17 '10 at 15:36
  • The tag embedded is for software running on devices, this question doesn't fit that. – starblue Apr 17 '10 at 19:53
  • 8
    @starblue Who said `embedded` is "for software running on devices" and only for that? Tags are for sets, sets can cover multiples areas (is `compiler` only for let's say javac? certainly not). So add more constraints to get the intersection if you want to restrict things. And because "embeddeed" is used for embeddable containers like Jetty, Jboss, GlassFish in the Java world (as Google will clearly show, e.g. http://www.google.com/search?q=jetty+embedded), because EJB3.1 has an "Embedded API", I would like to be able to query on jetty+embedded, glassfish+embedded, ejb+embedded, etc. – Pascal Thivent Apr 17 '10 at 20:43

3 Answers3

24

i'd use jetty embedded when the goal is to create a standalone application in which jetty is just one of the components (for example in an osgi container). if you just want to deploy some war's then a default jetty installation seems more preferable. i don't think the choice depends on whether you plan to deploy more than one webapp. when you embed jetty you'll have to do the plumping yourselves in your code.

Stefan De Boey
  • 2,344
  • 16
  • 14
18

Embedding jetty is handy in two cases I'm familiar with:

  1. JNI. It's a lot easier to make sure you've got the right things in the right class loader.

  2. Development. It's much easier to fire up an embedded jetty in eclipse than to dance around with the eclipse web tools and deal with deployments and debugger attaching.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
9

Have a look at the Winstone servlet container which allows you to distribute a single WAR file as an executable jar as a supported use case. This is what Hudson does.

grassyburrito
  • 1,213
  • 22
  • 32
Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • Winstone has since been cloned by the Jenkins (nee Hudson) project, and reworked to wrap Jetty. http://jenkins-ci.361315.n4.nabble.com/Winstone-is-now-powered-by-Jetty-td4678478.html – Thorbjørn Ravn Andersen Apr 16 '15 at 08:43