为什么我的Jetty 8启动失败了HttpServlet响应的ClassNotFoundException?我错过了什么步骤?
在Ubuntu 12.04.03上运行
我安装了openjdk 7:
sudo apt-get install openjdk-7-jdk
sudo apt-get install jetty8
但是当我用“service jetty8 start”启动jetty时它会失败,并且/var/log/start.log会显示:
引起:java.lang.ClassNotFoundException:javax.servlet.http.HttpServletResponse
完整堆栈跟踪是:
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
答案 0 :(得分:1)
请尝试使用此版本:
sudo apt-get install libservlet3.0-java
您需要获得与您的servlet-api版本匹配的实现。