NoClassDefFoundError在jetty上运行简单的rest app

时间:2013-12-09 15:26:04

标签: java eclipse jetty jax-rs

尝试运行简单的JAX-RS示例时出错。 我正在使用jaxrs-ri-2.4.1和带有“Run Jetty”插件的Jetty嵌入式服务器用于eclipse。 谢谢。

web.xml
<servlet>
   <servlet-name>restServlet</servlet-name>
   <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
   <init-param>
       <param-name>jersey.config.server.provider.packages</param-name>
       <param-value>path_to_class.FormsRestService</param-value>
   </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>restServlet</servlet-name>
    <url-pattern>/rest/</url-pattern>
</servlet-mapping>

FormsRestService.java
package path_to_class;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/") 
public class FormsRestService {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getStringHello(){
    return "Hello Jersey!";
}
}

短暂例外(或全文http://pastebin.com/fFMb7Y2a

Caused by:

java.lang.NoClassDefFoundError: org/glassfish/jersey/server/ContainerException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
......
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

我想到了码头7,现在我有这样的例外:pastebin.com/ZdRXzeED

1 个答案:

答案 0 :(得分:0)

jaxrs-ri-2.4.1希望您使用Glassfish。

请查看这个旧问题(以及两个答案)以寻求帮助。

Integrating Jetty with JAX-RS-Jersey