使用Framework V2,尝试获取要与端点一起使用的EntityManagerFactory实例,会产生java.lang.NoClassDefFoundError

时间:2017-10-07 16:50:41

标签: java google-app-engine google-cloud-platform google-cloud-endpoints

使用Google Cloud Framework V2更新项目后,将我的后端上传到应用引擎服务器,当我尝试访问EntityManagerFactory的某个实例时,会给我一个java.lang.NoClassDefFoundError。

我确实有一个EMF类,我打电话:

 public final class EMF {

 private static final EntityManagerFactory emfInstance = Persistence
    .createEntityManagerFactory("transactions-optional");

 private EMF() {
 }

 public static EntityManagerFactory get() {
return emfInstance;
 }

 }`

在app引擎V1上一切都很好。有线索吗?

编辑3(回答Mickael请求),登录App Engine :(调用EntityManagerFactory的所有servlet或端点抛出相同的异常)

> 
2017-10-10 (15:09:52.925)
Uncaught exception from servlet
java.lang.NoClassDefFoundError: Could not initialize class com.example.app.EMF
at com.example.app.CustomContactImageEndpoint.getEntityManager(CustomContactImageEndpoint.java:585)
at com.example.app.CustomContactImageEndpoint.findContactImagesMoment(CustomContactImageEndpoint.java:79)
at com.example.app.ContactImageServlet.doGetImpl(ContactImageServlet.java:33)
at com.example.app.feed2.WPHttpServlet.doGet(WPHttpServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
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.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:58)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
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.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:257)
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 com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:680)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:642)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:612)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:297)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:320)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:312)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:274)
at java.lang.Thread.run(Thread.java:745)
request_id: "59dcc69f00ff0dc24abd77a6f40001737e6d6773746166663839000132000100"
timestamp: "2017-10-10T13:09:52.925Z" 

我的web.xml已更改为在V2中调用EndpointsServlet而不是V1的SystemServiceServlet,并且还重新生成了客户端点。

编辑4:

我认为这与我在app引擎上的部署有关。查看gradle中的部署日志,未上载WEB-INF / classes和WEB-INF / lib。我添加了

   stage { 
    enableJarClasses = true
}

但是仍然没有上传WEB-INF / lib文件。我现在在服务器上抛出了不同的异常

    Uncaught exception from servlet
Class Contact for query has not been resolved. Check the query and any imports/aliases specification
org.datanucleus.exceptions.ClassNotResolvedException: Class Contact for query has not been resolved. Check the query and any imports/aliases specification
at org.datanucleus.query.compiler.JavaQueryCompiler.resolveClass(JavaQueryCompiler.java:906)...

0 个答案:

没有答案