1

我在服务器端有一个基本服务,它只是在表上进行查找。该代码在隔离代码/ JUnit 测试上运行良好。

当我将它集成到服务器端时,我得到一个异常:

org.apache.torque.TorqueException: Torque is not initialized
    at org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:824)
    at org.apache.torque.Torque.getConnection(Torque.java:290)
    at org.apache.torque.util.Transaction.beginOptional(Transaction.java:106)
    at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:651)
    at org.simmental.datamods.om.BaseAcctPeer.doSelectVillageRecords(BaseAcctPeer.java:527)
    at org.simmental.datamods.om.BaseAcctPeer.doSelectVillageRecords(BaseAcctPeer.java:501)
    at org.simmental.datamods.om.BaseAcctPeer.doSelect(BaseAcctPeer.java:397)
    at org.redangus.dao.services.AccountServices.getAccountByPrefix(AccountServices.java:15)
    at org.redangus.signup.server.HerdPrefixValidationServiceImpl.validatePrefixServer(HerdPrefixValidationServiceImpl.java:39)
    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:606)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:68)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:370)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
    at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:744)

它看起来很像 Google AppEngine 的一些问题,但它没有在我的环境中激活。

我激活 GAE 看看会发生什么,我得到:

java.lang.NoClassDefFoundError: org/apache/torque/TorqueException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
    at java.lang.Class.getConstructor0(Class.java:2803)
    at java.lang.Class.newInstance(Class.java:345)
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
    at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    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:127)

[..]

Caused by: java.lang.ClassNotFoundException: org.apache.torque.TorqueException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:216)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 42 more

这完全有道理……

当我回到没有 AppEngine 的情况下,它仍然失败,就像我的第一个示例一样。

我不想在 AppEngine 上运行我的代码,这只是一个测试。

我不认为 Torque 实际上在这里做任何坏事......

4

2 回答 2

0

AppEngine 错误似乎表明 Torque 不在您的WEB-INF/lib

于 2014-04-09T22:48:14.150 回答
0

好的,这是一个奇怪的情况,但是:

  • 当我在命令行中使用代码时,数据库没有启动。

  • 当我在 GWT 中使用相同的代码时,我必须在我的代码中对其进行初始化Database.start()

所以,我无缘无故地责怪 AppEngine :)。

于 2014-04-10T21:31:56.140 回答