java.lang.ClassNotFoundException:org.glassfish.jersey.servlet.ServletContainer [英] java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer

查看:1140
本文介绍了java.lang.ClassNotFoundException:org.glassfish.jersey.servlet.ServletContainer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你可能会觉得这是一个重复的问题,但是没有一个同一个标题的问题解决了我的问题。我使用Jersey 2.0在Eclipse中创建一个RESTful Web服务,我使用Tomcat 7.0作为我的服务器,我有以下 web.xml

You may feel this is a duplicated question, but none of the questions with the same title solve my problems. I am using Jersey 2.0 creating a RESTful web service in Eclipse, I use Tomcat 7.0 as my server, I have the following web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <servlet>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>com.shop.domain</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>JAX-RS Servlet</servlet-name>
    <url-pattern>/jaxrs/*</url-pattern>
  </servlet-mapping>
</web-app>

我有一个简单的类叫你好:

I have a simple class called Hello:

@Path("customers")
public class Hello {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getCustomer() {
        return "hello";
    }
}

我有一个泽西库,名为球衣

I have a Jersey library called jersey:

每次我运行这个项目时,我都收到了错误

Every time I ran this project, I got error of

java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer

任何想法?

推荐答案

等等,你说你有一个泽西图书馆叫做球衣,你创建了一个用户库并将其命名为球衣?如果是这样,请尝试将您的球衣jar文件复制到 WebContent - > WEB-INF - > lib 中。

Wait, you said you have a Jersey library called jersey, did you create a User Library and name it jersey? If so, try to copy your jersey jar files into WebContent -> WEB-INF -> lib.

这篇关于java.lang.ClassNotFoundException:org.glassfish.jersey.servlet.ServletContainer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆