1

Why is my Jetty 8 startup failing with a ClassNotFoundException for HttpServlet response? What step have I missed?

Running on Ubuntu 12.04.03

I installed openjdk 7 with:

sudo apt-get install openjdk-7-jdk

  • installed jetty 8 with:

sudo apt-get install jetty8

  • modified the /etc/default/jetty8 file to set NO_START=0 & the JAVA_HOME=... value.

But when I start jetty with "service jetty8 start" it fails, and the /var/log/start.log shows:

Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletResponse

The full stack trace is:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:457)
        at org.eclipse.jetty.start.Main.start(Main.java:602)
        at org.eclipse.jetty.start.Main.main(Main.java:82)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletResponse
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2483)
        at java.lang.Class.getConstructor0(Class.java:2793)
        at java.lang.Class.newInstance(Class.java:345)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:333)
        at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:291)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1203)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
        ... 7 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletResponse
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 16 more

Usage: java -jar start.jar [options] [properties] [configs]
       java -jar start.jar --help  # for more information
sea-rob
  • 2,275
  • 1
  • 22
  • 22
  • what do you see when you type `java -version` in your console? – ljgw Nov 26 '13 at 21:43
  • $ java -version java version "1.7.0_25" OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode) – sea-rob Nov 26 '13 at 21:44
  • 1
    Hmm, well that seems ok. However; take a look at this answer: http://stackoverflow.com/a/1022941/2430030. – ljgw Nov 26 '13 at 21:49
  • That feels like progress. I ran "apt-get install libservlet2.5-java" and it installed something, but same result. I'm surprised the servlet jar isn't bundled in jetty. – sea-rob Nov 26 '13 at 21:54
  • Under /usr/share/jetty8/lib, I do see servlet-api-3.0.jar. Why isn't the startup picking that up? – sea-rob Nov 26 '13 at 21:59
  • Sorry, that was an unforeseen side effect of the link,... the 2.5 servlet library is probably the incorrect version for you. – ljgw Nov 26 '13 at 22:13

1 Answers1

1

Try this version instead:

sudo apt-get install libservlet3.0-java

You need to get the implementation that matches your servlet-api version.

ljgw
  • 2,751
  • 1
  • 20
  • 39
  • Good point, but still no luck: Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletResponse – sea-rob Nov 26 '13 at 22:24
  • Darn, sorry... out of good points for tonight I guess,.. Anyway, Good luck! – ljgw Nov 26 '13 at 22:26