最近在学习webService,使用CXF开发REST风格的服务
启动这个链接的项目报错:https://my.oschina.net/huangyong/blog/294324,我的代码跟他所示一样
错误代码如下:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/SessionManager
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory.getOrCreate(JettyHTTPServerEngineFactory.java:117)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory.createJettyHTTPServerEngine(JettyHTTPServerEngineFactory.java:273)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.retrieveEngine(JettyHTTPDestination.java:121)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.finalizeConfig(JettyHTTPDestination.java:154)
at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:281)
at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:84)
at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:63)
at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:173)
at com.medex.service.Server.main(Server.java:31)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.SessionManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more
我不太懂jetty,我是直接在main方法上右键运行(tomcat)了,谢谢。
从异常来看你的项目中有 jetty 依赖,但你用的是 tomcat 启动,所以要将 jetty 的东西删干净
如果你用的是 Jetty ,就不能用 tocmat 来启动。同时要注意将 jetty-server 升级到 2011.8 这个版本,jfinal 升级到 3.5 版