gpt4 book ai didi

java - Jersey + App Engine 项目启动错误

转载 作者:行者123 更新时间:2023-12-01 05:30:08 26 4
gpt4 key购买 nike

进行了大量搜索,但没有成功。

我正在尝试制作一个集成 Jersey 和 Google App Engine 的“hello world”应用程序。在 Eclipse 中,我创建了一个“Web 应用程序项目”并将 Jersey JAR 添加到构建路径中。然后我修改了 web.xml,它看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>Jersey Web Application</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.example.myJersey</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

在“com.example.myJersey”包中,我有 HelloWorldResource.java,以下是摘录:

// The Java class will be hosted at the URI path "/helloworld"
@Path("/helloworld")
public class HelloWorldResource {

// The Java method will process HTTP GET requests
@GET
// The Java method will produce content identified by the MIME Media
// type "text/plain"
@Produces("text/plain")
public String getClichedMessage() {
// Return some cliched textual content
return "Hello World";
}
}

当我单击“运行”时,出现此错误:

INFO: Successfully processed C:\Users\upelsin\wtf-rest\war\WEB-INF/web.xml
фев 02, 2012 5:05:16 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed Jersey Web Application: java.lang.IncompatibleClassChangeError: Implementing class
фев 02, 2012 5:05:16 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed com.google.appengine.tools.development.DevAppEngineWebAppContext@1aa58969{/,C:\Users\upelsin\wtf-rest\war}: java.lang.IncompatibleClassChangeError: Implementing class
фев 02, 2012 5:05:16 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed JettyContainerService$ApiProxyHandler@6d26b88a: java.lang.IncompatibleClassChangeError: Implementing class
фев 02, 2012 5:05:16 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: Error starting handlers
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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 com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.init(WebAppResourceConfig.java:102)
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:89)
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:74)
at com.sun.jersey.spi.container.servlet.WebComponent.getWebAppResourceConfig(WebComponent.java:672)
at com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:414)
at com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:581)
at com.sun.jersey.spi.container.servlet.WebServletConfig.getDefaultResourceConfig(WebServletConfig.java:87)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:703)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)

编辑:也许 web.xml 中配置错误。看来 Jetty 不喜欢 Jersey 的 servlet 类。

我将不胜感激任何形式的帮助。

最佳答案

我最近整理了一个project template在 GitHub 上,结合了 Jersey 和 Guice for AppEngine。与正在运行的应用程序进行比较可能会有所帮助。

关于java - Jersey + App Engine 项目启动错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9115931/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com