我有一个应用引擎连接的 android 应用程序。当我尝试进行后端 api 调用时,设备在日志 cat 中的 EMF 文件上收到 java.lang.NoClassDefFoundError。然后当我检查应用引擎仪表板上的日志时,我看到 java.lang.ExceptionInInitialzer 错误。
EMF.java
package com.theincrowd;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class EMF {
protected static final EntityManagerFactory emfInstance =
Persistence.createEntityManagerFactory("transactions-optional");
private EMF() {
}
public static EntityManagerFactory get() {
return emfInstance;
}
}
这是来自应用引擎控制台的日志
com.google.api.server.spi.SystemService invokeServiceMethod: Could not initialize class com.theincrowd.EMF
java.lang.NoClassDefFoundError: Could not initialize class com.theincrowd.EMF
at com.theincrowd.PromoterEndpoint.getEntityManager(PromoterEndpoint.java:171)
at com.theincrowd.PromoterEndpoint.insertPromoter(PromoterEndpoint.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:45)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:337)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:162)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
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 org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
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 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.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:483)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:490)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:777)
at com.google.tracing.TraceContext$DoInTraceContext.runInContext(TraceContext.java:754)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:345)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:337)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:487)
at java.lang.Thread.run(Thread.java:722)
我阅读了这篇文章http://javaeesupportpatterns.blogspot.com/2012/07/javalangnoclassdeffounderror-how-to.html中的解释 但是,我无法识别代码中的问题。