gpt4 book ai didi

java - 无法让使用谷歌应用程序引擎制作的应用程序运行

转载 作者:行者123 更新时间:2023-12-01 04:40:58 25 4
gpt4 key购买 nike

我一直在关注this tutorial

使用 Google App Engine 创建待办事项列表应用程序。当我去部署它时,出现此错误

java.lang.ExceptionInInitializerError:

通过查看控制台中的输出,它链接到我的代码中的以下行

EntityManager em = EMFService.get().createEntityManager();

我在这个网站上看到过类似的内容,但没有解决方案。以下是与错误相关的类

Dao.Java

public enum Dao {
INSTANCE;

@SuppressWarnings("unchecked")
public List<Todo> listTodos() {

EntityManager em = EMFService.get().createEntityManager();
Query q = em.createQuery("select m from Todo m");
List<Todo> todos = q.getResultList();
return todos;
}

public void add(String userID, String summery, String description, String url) {

synchronized(this) {

EntityManager em = EMFService.get().createEntityManager();
Todo todo = new Todo( userID, summery, description, url );
em.persist(todo);
em.close();

}
}

@SuppressWarnings("unchecked")
public List<Todo> getTodo(String userID) {

EntityManager em = EMFService.get().createEntityManager(); // Error links to here
Query q = em.createQuery("select t from Todo t where t.author = :userID");
q.setParameter("userID", userID);
List<Todo> todos = q.getResultList();

return todos;
}

public void remove(long id) {

EntityManager em = EMFService.get().createEntityManager();

try {
Todo todo = em.find(Todo.class, id);
em.remove(todo);
} finally {
em.close();
}
}
}

EMFService.java

public class EMFService {

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

private EMFService() {}

public static EntityManagerFactory get() {
return emfInstance;
}
}

非常感谢任何帮助。

控制台输出

WARNING: Nested in javax.servlet.ServletException: java.lang.NoClassDefFoundError:        Could not initialize class com.chrismcnulty.gaetutorial.EMFService:
java.lang.NoClassDefFoundError: Could not initialize class com.chrismcnulty.gaetutorial.EMFService
at com.chrismcnulty.gaetutorial.Dao.getTodo(Dao.java:35)
at org.apache.jsp.TodoApplication_jsp._jspService(TodoApplication_jsp.java:92)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at com.google.appengine.tools.development.PrivilegedJspServlet.access$101(PrivilegedJspServlet.java:23)
at com.google.appengine.tools.development.PrivilegedJspServlet$2.run(PrivilegedJspServlet.java:61)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.PrivilegedJspServlet.service(PrivilegedJspServlet.java:58)
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.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:61)
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:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerServersFilter.doFilter(DevAppServerServersFilter.java:106)
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:94)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:421)
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)

最佳答案

这实际上很可能是由于它无法初始化 EMFService 类造成的。静态成员在类加载时初始化。实际失败的行是:

私有(private)静态最终EntityManagerFactory emfInstance = Persistence.createEntityManagerFactory(“事务可选”);

“交易可选”可能是错误的吗?

关于java - 无法让使用谷歌应用程序引擎制作的应用程序运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16551302/

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