我使用带有 Google App Engine 和 GWT 的 Restlet 得到 NoClassDefFoundError。
我正在尝试获取我的对象的 Json 表示。我得到的错误是:
java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonGenerator$Feature
我得到错误的方法的基本框架是:
@Get("json")
public Representation getProduct() {
Product product = new Product("whatever");
return new JacksonRepresentation<Product>(MediaType.APPLICATION_JSON, product);
}
JsonFactory
最初,当仅使用 Restlet 提供的 JAR 时,我得到了一个类错误。然后我下载了“jackson-all-1.9.7.jar”。此后,该错误已被此新错误所取代。
知道发生了什么吗?也许我错过了一些图书馆,但我可以弄清楚哪些图书馆。
编辑:包括堆栈跟踪。我删除了所有库,然后运行了 Restlet org.restlet.ext.jackson
JAR。此外,为了检查该类在编译时是否可用,如下面的答案所暗示的那样,我尝试在 Eclipse 中检查类和包的自动完成功能,但它没有显示任何内容。我假设这意味着它在编译时也不可用。
java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonFactory
at org.restlet.ext.jackson.JacksonRepresentation.createObjectMapper(JacksonRepresentation.java:118)
at org.restlet.ext.jackson.JacksonRepresentation.getObjectMapper(JacksonRepresentation.java:164)
at org.restlet.ext.jackson.JacksonRepresentation.write(JacksonRepresentation.java:205)
at org.restlet.representation.WriterRepresentation.write(WriterRepresentation.java:104)
at org.restlet.engine.http.ServerCall.writeResponseBody(ServerCall.java:550)
at org.restlet.engine.http.ServerCall.sendResponse(ServerCall.java:488)
at org.restlet.ext.servlet.internal.ServletCall.sendResponse(ServletCall.java:492)
at org.restlet.engine.http.adapter.ServerAdapter.commit(ServerAdapter.java:197)
at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:151)
at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1028)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:369)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
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)
... 40 more