1

我正在尝试在 App Engine 中使用 Jersey 进行原型设计。当我将应用程序部署到 {app}.appspot.com 时,我会看到以下错误:

2013-08-06 08:19:52.749
com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider: The provider class, class com.sun.jersey.atom.rome.impl.provider.entity.AtomFeedProvider, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.SecurityException: Unable to get members for class com.sun.jersey.atom.rome.impl.provider.entity.AtomFeedProvider
    at com.google.appengine.runtime.Request.process-5fd4a6aad8a8feef(Request.java)
    at java.lang.Class.getDeclaredMethods(Class.java:256)
    at com.sun.jersey.core.reflection.MethodList.getAllDeclaredMethods(MethodList.java:70)
    at com.sun.jersey.core.reflection.MethodList.<init>(MethodList.java:64)
    at com.sun.jersey.core.spi.component.ComponentConstructor.getPostConstructMethods(ComponentConstructor.java:131)
    at com.sun.jersey.core.spi.component.ComponentConstructor.<init>(ComponentConstructor.java:123)
    at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:165)
    at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
    at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
    at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1310)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:168)
    at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:774)
    at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:770)
    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:765)
    at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:489)
    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319)
    at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
    at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:435)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:442)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:186)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:306)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:298)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:439)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    ... 41 more
Caused by: java.lang.NoClassDefFoundError: com/sun/syndication/io/FeedException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2447)
    ... 41 more
Caused by: java.lang.ClassNotFoundException: com.sun.syndication.io.FeedException
    at com.google.appengine.runtime.Request.process-5fd4a6aad8a8feef(Request.java)
    ... 41 more

以下是web.xml中的设置

<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.feature.DisableWADL</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.tattva.service</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

以下 jar 在我的构建路径中。

    asm-3.1.jar
    jaxb-api-2.2.4.jar
    stax-api-1.0-2.jar
    jackson-core-asl-1.7.1.jar
    jackson-jaxrs-1.7.1.jar
    jackson-mapper-asl-1.7.1.jar
    jackson-xc-1.7.1.jar
    jettison-1.1.jar
    activation-1.1.jar
    jaxb-impl-2.2.4-1.jar
    jersey-client-1.8.jar
    jersey-core-1.8.jar
    jersey-json-1.8.jar
    jersey-server-1.8.jar

关于出了什么问题的任何想法?

4

3 回答 3

2

我遇到了完全相同的错误,也有同样的问题。我开始使用 jersey 库,最后我下载了 jersey 1.9.1 的最后一个版本作为 zip 文件,以及 jar 文件: https ://jersey.java.net/download.html

现在在项目中我有: jersey-bundle-1.19.1.jar jersey-multipart-1.19.1.jar jersey-atom-abdera-1.19.1.jar

现在没有启动错误。

于 2016-10-11T12:08:10.313 回答
2

由于这个问题在 3 年后仍然有意见,所以这个错误的根本原因是以下异常:

java.lang.NoClassDefFoundError: com/sun/syndication/io/FeedException

这反过来又是由于该类缺少依赖关系引起的,com.sun.syndication.io.FeedException该类是RSS 和 Atom 提要的ROME 框架的一部分。com.sun.jersey.atom.rome.impl.provider.entity.AtomFeedProvider泽西的班级需要它。

在项目页面的 Maven Central 链接之后,您可以将以下依赖项添加到您的项目中以解决此问题:

马文:

<dependency>
    <groupId>com.rometools</groupId>
    <artifactId>rome</artifactId>
    <version>1.7.1</version>
</dependency>

摇篮:

compile 'com.rometools:rome:1.7.1'

或者直接下载 JAR并将其添加到您的项目中。

于 2017-03-10T21:50:53.557 回答
1

看起来您正在使用 Rome 项目中的一些 RSS 实用程序,但您的路径中没有那个 jar。

我认为您可以在以下位置获取 jar: https ://rometools.jira.com/wiki/display/ROME/Home

于 2013-08-06T17:03:42.887 回答