java.lang.NoSuchFieldError:使用Cloud SQL在GAE上运行的JPA 1.0 Hibernate上的NONE问题

时间:2015-09-28 10:12:22

标签: java hibernate google-app-engine jpa

我在cloud sql上的dev服务器上执行本机查询时遇到问题 下面我附上了代码,错误日志和配置文件。我正在使用JPA1.0 hibernate和谷歌端点。代码在我的本地服务器上运行非常顺利但在云sql上抛出错误。

String sql = "SELECT * FROM Account where Account_ShortCode = ?";
        EntityManagerFactory emf = EMF.getEntityManagerFactory("xxxxx");
        EntityManager em = emf.createEntityManager();
        try {
            em.getTransaction().begin();
            Query query = em.createNativeQuery(sql);
            query.setParameter(1, Tag);
            AccountBean A = (AccountBean) query.getSingleResult();
        }catch(NoResultException e) {
            Tagchk = false;
        } catch(Exception e){
            Logger log = Logger.getLogger("Utility_Func");
            log.log(Level.WARNING, "Tag Unique Exception", e);
        }

错误记录

    com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backed method
java.lang.NoSuchFieldError: NONE
    at org.hibernate.ejb.QueryImpl.<init>(QueryImpl.java:620)
    at org.hibernate.ejb.QueryImpl.<init>(QueryImpl.java:81)
    at org.hibernate.ejb.AbstractEntityManagerImpl.createNativeQuery(AbstractEntityManagerImpl.java:731)
    at backend.BR.Utility_Func.checkTag(Utility_Func.java:56)
    at backend.BR.Utility_Func.Generate_Tag(Utility_Func.java:76)
    at backend.BR.SignupRules.SignupUser(SignupRules.java:43)
    at backend.apis.userApi.UserRegister(userApi.java:50)
    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:44)
    at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
    at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
    at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
    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)

1 个答案:

答案 0 :(得分:0)

我可以通过删除以下条目格式的gradle文件来修复代码

compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'