Ruud
Ruud

Reputation: 21

Upgrading from jetty 7 to jetty 9

I'm running a Jetty 7 web application and would like to upgrade to jetty 9. The project is based on Spring framework and uses Maven for dependency management. Once I upgrade Jetty, it fails to start because of the following error:

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:473)
at org.eclipse.jetty.start.Main.start(Main.java:615)
at org.eclipse.jetty.start.Main.main(Main.java:96)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
at java.lang.Class.getConstructor0(Class.java:2803)
at java.lang.Class.newInstance(Class.java:345)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:348)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:296)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1262)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1197)
... 7 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
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:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 16 more

I have tried to identify dependencies that might cause conflicts with servlet-api, using the maven dependency tree tool but that didn't help much. The error is still there.

Currently running Jetty version 7.2.2.v20101205 and would like to upgrade to 9.1.3.v20140225. NB. This error also occurs when upgrading Jetty to version 7.6.14.v20131031. Basically any other version then the one I am using right now causes this error.

Any ideas?

Upvotes: 1

Views: 2348

Answers (2)

Lagopus
Lagopus

Reputation: 66

I would start checking if there is any servlet-api related libraries inside webapp war.

Upvotes: 0

gizmo
gizmo

Reputation: 11909

Jetty 9 is based on the Servlet container 3.0 version. I guess your maven dependencies references the 2.5 or older version of the API

Prior to 3.0:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.5</version>
</dependency>

3.0.1 and upper:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>3.0.1</version>
</dependency>

Upvotes: 0

Related Questions