java.lang.ClassNotFoundException:com.sun.jersey.spi.container.servlet.ServletContainer [英] java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

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

问题描述

我正在使用泽西+ Google应用引擎,建立一个简单的hello world应用程序两天。对于简单的AppEngine项目,我遵循这些教程,并且两个工作都很好
https: //developers.google.com/appengine/docs/java/gettingstarted/creating
https://developers.google.com/appengine/docs/java/webtoolsplatform

I am trying to build a simple hello world application for two days using Jersey + Google app engine. For simple AppEngine project I followed these tutorials and both works just fine https://developers.google.com/appengine/docs/java/gettingstarted/creating https://developers.google.com/appengine/docs/java/webtoolsplatform

但是现在我试图添加泽西和跟随本教程 http://www.vogella.com/articles/REST/article.html

But now I am trying to add Jersey and following this tutorial http://www.vogella.com/articles/REST/article.html.

但服务器不断给我


java.lang.ClassNotFoundException :com.sun.jersey.spi.container.servlet.ServletContainer

java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

当我将这些行添加到 / em>:

when I add these lines in 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>TestServer</display-name>
<servlet>
    <servlet-name>Jersey REST Service</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.test.myproject</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>

我已经下载了Jersey JAX-RS 2.1 RI捆绑此处,并将所有jar文件添加到 WEB-INF / lib 文件夹,如教程中所述。即使在两天之后,还没有任何工作。我在Google上搜索了好几次,显然,使用Maven的人已经以某种方式解决了这个问题,但是我没有使用Maven,也没有写过该教程的人。

I have downloaded Jersey JAX-RS 2.1 RI bundle from here and have added all jar files in WEB-INF/lib folder as described in tutorial. And even after two days nothing is working. I have searched several times on Google and apparently people who are using Maven have solved it somehow but I am not using Maven neither did the guy who wrote that tutorial.

只需检查即使 com.sun.jersey.spi.container.servlet.ServletContainer 是否存在于导入的 Jersey jars 我试图用Java编写这个完全限定名字,让智能感知完成名字,但是在 com.sun之后,我无法获得任何智能感知。所以我最后一个猜测是,在最新的泽西版本中已经有一些包重新排列,而球衣已经不在里面的com.sun 。我很疲惫,我会感谢任何一种帮助。

Just to check if even com.sun.jersey.spi.container.servlet.ServletContainer exists in imported Jersey jars I tried to just write this fully qualified name in Java and let the intellisense finish names but I couldn't get any intellisense after com.sun.je so my last guess is that there have been some package rearrangement in latest Jersey build and jersey is no longer inside com.sun. I am exhausted and I would appreciate any kind of help.

推荐答案

您已经下载了Jersey 2(JAX-RS 2的RI)。你所指的教程使用泽西1.从(这里),应该足够你。

You have downloaded Jersey 2 (which RI of JAX-RS 2). The tutorial you're referring to uses Jersey 1. Download Jersey 1.17.1 from (here), should be sufficient for you.

泽西1使用 com.sun .jersey ,泽西2使用 org.glassfish.jersey 因此是异常。

Jersey 1 uses com.sun.jersey, and Jersey 2 uses org.glassfish.jersey hence the exception.

另请注意, init-param com.sun.jersey 不会被泽西2认可。

Also note that also init-param starting with com.sun.jersey won't be recognized by Jersey 2.

在泽西岛2注册资源和提供商包含有关如何注册的其他信息泽西岛的课程/实例2.

Registering Resources and Providers in Jersey 2 contains additional info on how to register classes/instances in Jersey 2.

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

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