16

Usually Jetty is mentioned as the lightweight alternative when it comes to servlet containers like Tomcat and App Servers like Glassfish.

I want to run a RESTful service on CloudFoundry. Using jetty-runner

java -jar target/dependency/jetty-runner.jar target/*.war

works kind of fine, except I kind of run into problems running Jetty 9.1.3 (current stable) /w Java 8. So I contributed a patch to fix this issue and some other minor code cleanup patches. Hereby I saw the code of Jetty which was not in a shape I hoped it to be...

Well I just don't want to entrust my enterprise app to Jetty and looking for alternatives. Also with 5.x MB, jetty-runner.jar is still huge. I managed to strip it down to 1.6 MB and I was still able to run my app. So an even more lightweight approach is feasible.

Is there a lightweight version of GlassFish or Tomcat. I just need the servlet-api.jar (v3.1) being run in a web server context. No JSP, no websocket-server, no other Voodoo.

Alex
  • 8,245
  • 8
  • 46
  • 55
  • 2
    Is Jetty not lightweight enough? Its quality is not trustworthy? The history of the patch you contributed shows that Your problem was caused by using conflicting ASM versions. It wasn't Jetty fault. Sorry, but whole your question looks like... rant. – G. Demecki Jun 25 '15 at 12:51

3 Answers3

26

Undertow is a flexible performant web server written in java, providing both blocking and non-blocking API’s based on NIO.

Undertow has a composition based architecture that allows you to build a web server by combining small single purpose handlers. The gives you the flexibility to choose between a full Java EE servlet 3.1 container, or a low level non-blocking handler, to anything in between.

Undertow is extremely lightweight, with the Undertow core jar coming in at under 1Mb. It is lightweight at runtime too, with a simple embedded server using less than 4Mb of heap space.

Link to official site.

DmitryKanunnikoff
  • 2,226
  • 2
  • 22
  • 35
  • I'm looking for a code snippet how to launch a web app that is defined in my web.xml; http://undertow.io/documentation/servlet/deployment.html is empty at the moment. – Alex Mar 26 '14 at 17:41
  • 1
    Perhaps this is what you need: https://github.com/undertow-io/undertow/tree/master/examples – DmitryKanunnikoff Mar 26 '14 at 18:29
  • Unfortunately I haven't found any example that starts an http server based on a web.xml configuration. – Alex Mar 27 '14 at 00:57
  • 2
    I think you need to pack the web.xml file in the *.war archive. Perhaps it will be helpful: https://github.com/undertow-io/jastow/blob/master/src/test/java/io/undertow/test/jsp/basic/SimpleJspTestCase.java and https://issues.jboss.org/browse/UNDERTOW-198 – DmitryKanunnikoff Mar 27 '14 at 04:02
  • It is relatively straightforward to write some code to parse a simple web.xml and configure Undertow with the defined servlets, mappings, init params and so on. I can understand why Undertow team leaves full war support including web.xml to WildFly... – jugglingcats Apr 28 '15 at 08:46
  • @jugglingcats - no, it's not straightforward at all. – stepanian Jan 09 '16 at 07:57
  • Comparing undertow-servlet 2.1.0 and jetty-servlet 9.4.33 (and include all dependencies in a fat JAR) undertow has 4MB and Jetty only 2MB... – Robert Oct 30 '20 at 09:02
4

Since you tagged this as Jersey, I'll mention that the Jersey docs show examples of how to deploy using the HTTP server that is built-in to the Java runtime:

https://jersey.java.net/documentation/latest/deployment.html#deployment.http

Harald
  • 140
  • 3
  • 1
    Unfortunately the Jersey container does not support any servlet deployment descriptors, i.e. web.xml and the Servlets that have been defined there. – Alex Mar 26 '14 at 16:51
0

Going through Pippo system requirements, I found TJWS - Tiny Java Web Server and Servlet Container, BSD license.

Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91