app enigine 1.9.18,JDO 3.1.3 java.lang.ClassCastException java.lang.Long无法强制转换为java.lang.Double

时间:2015-03-23 12:02:55

标签: java google-app-engine jdo

我打电话给

时遇到这个例外
jobInDatabase = pm.getObjectById(DAOJob.class, job.getKey());

导致以下异常

java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Double
at com.eurekaapp.server.dao.mappedobjects.DAOJob.jdoReplaceField(DAOJob.java)
at com.eurekaapp.server.dao.mappedobjects.DAOJob.jdoReplaceFields(DAOJob.java)
at org.datanucleus.state.JDOStateManager.replaceFields(JDOStateManager.java:1935)
at org.datanucleus.state.JDOStateManager.replaceFields(JDOStateManager.java:1962)
at com.google.appengine.datanucleus.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:567)
at org.datanucleus.state.JDOStateManager.loadFieldsFromDatastore(JDOStateManager.java:1638)
at org.datanucleus.state.JDOStateManager.validate(JDOStateManager.java:3511)
at org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:3379)
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1722)
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1740)
at com.eurekaapp.server.dao.GoogleCloud.getJob(GoogleCloud.java:712)
at com.eurekaapp.server.service.DAOServiceImpl.getJob(DAOServiceImpl.java:661)
at com.eurekaapp.server.api.client.AddJobEvent.doPost(AddJobEvent.java:55)
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 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:35)
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:43)
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:254)
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.run(JavaRuntime.java:527)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:745)

我不确定哪个字段会抛出此异常? 我在obj中有3个双打 - 重量0 deliveryLongitude 0 deliveryLatitude 0

其余数字都很长。目前这只发生在这一个对象上。

如果没有传入任何值,默认情况下会设置这些值。如果我将这些默认值设置为实际双打,可能会纠正此问题。

以下是服务器上的一些日志:

    I 12:16:05.092 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,091 DEBUG Request 6CDEEF07 class:doPost:45 - user.isParsingSuccessfull()
I 12:16:05.093 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,092 DEBUG Request 6CDEEF07 class:isReceivedVersionCorrect:1830 - isReceivedVersionCorrect(): starting
I 12:16:05.094 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,093 DEBUG Request 6CDEEF07 class:isReceivedVersionCorrect:1833 - isReceivedVersionCorrect(): try
I 12:16:05.095 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,094 DEBUG Request 6CDEEF07 class:isReceivedVersionCorrect:1837 - isReceivedVersionCorrect(): version correct, version[17]
I 12:16:05.096 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,095 DEBUG Request 6CDEEF07 class:isReceivedVersionCorrect:1846 - isReceivedVersionCorrect(): successfull true
I 12:16:05.097 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,096 DEBUG Request 6CDEEF07 class:doPost:47 - daoService.isReceivedVersionCorrect(passedJSONArray.getJSONObject(0))
I 12:16:05.098 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,097 DEBUG Request 6CDEEF07 class:doPost:49 - passedJSONArray[1]
I 12:16:05.099 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,098 DEBUG Request 6CDEEF07 class:isReceivedJobEventValid:1962 - isReceivedJobEventValid(): starting
I 12:16:05.100 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,099 DEBUG Request 6CDEEF07 class:isReceivedJobEventValid:1965 - isReceivedJobEventValid(): try
I 12:16:05.101 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,100 DEBUG Request 6CDEEF07 class:isReceivedJobEventValid:1989 - DAOJobEvent() jobEvent.setParsingSuccessfull(true); DAOJobEvent [key=null, localID=95, jobID=5351674944159744, eventType=11, eventTime=Sun Mar 22 19:07:08 UTC 2015, latitude=53.325, longitude=-6.32569, notes=This job has been finished automatically by the phone, storedEventTime=Mon Mar 23 12:16:05 UTC 2015, companyID=6037653766012928, userID=6012377212387328, nanoTime=3020586876124620, sequence=null]
I 12:16:05.102 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,101 DEBUG Request 6CDEEF07 class:isReceivedJobEventValid:1996 - DAOJobEvent() returning
I 12:16:05.103 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,102 DEBUG Request 6CDEEF07 class:getJob:706 - getJob(): starting
I 12:16:05.104 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,103 DEBUG Request 6CDEEF07 Cache:debug:58 - Level 1 Cache of type "soft" initialised
I 12:16:05.105 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,104 DEBUG Request 6CDEEF07 Persistence:debug:58 - Object Manager "org.datanucleus.ObjectManagerImpl@1456e6b" opened for datastore "com.google.appengine.datanucleus.DatastoreManager@ba090c" with txn="org.datanucleus.TransactionImpl@1544f26"
I 12:16:05.107 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,106 DEBUG Request 6CDEEF07 Cache:debug:58 - Object with id "com.eurekaapp.server.dao.mappedobjects.DAOJob:5351674944159744" not found in Level 1 cache [cache size = 0]
I 12:16:05.108 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,107 DEBUG Request 6CDEEF07 Cache:debug:58 - Object with id "com.eurekaapp.server.dao.mappedobjects.DAOJob:5351674944159744" not found in Level 2 cache
I 12:16:05.109 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,108 DEBUG Request 6CDEEF07 Cache:debug:58 - Object "com.eurekaapp.server.dao.mappedobjects.DAOJob@4adf6a" (id="com.eurekaapp.server.dao.mappedobjects.DAOJob:5351674944159744") added to Level 1 cache (loadedFlags="[NNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN]")
I 12:16:05.181 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,109 DEBUG Request 6CDEEF07 Lifecycle:debug:58 - Object "com.eurekaapp.server.dao.mappedobjects.DAOJob@4adf6a" (id="com.eurekaapp.server.dao.mappedobjects.DAOJob:5351674944159744") has a lifecycle change : "HOLLOW"->"P_NONTRANS"
I 12:16:05.182 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,181 DEBUG Request 6CDEEF07 Connection:debug:58 - Created ManagedConnection using DatastoreService = com.google.appengine.api.datastore.DatastoreServiceImpl@191c505
I 12:16:05.183 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,182 DEBUG Request 6CDEEF07 Connection:debug:58 - Connection added to the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@11de9d0 for key=org.datanucleus.ObjectManagerImpl@1456e6b in factory=ConnectionFactory:nontx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@f2b4dc]
I 12:16:05.185 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,184 DEBUG Request 6CDEEF07 Connection:debug:58 - Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@11de9d0 for key=org.datanucleus.ObjectManagerImpl@1456e6b in factory=ConnectionFactory:nontx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@f2b4dc]
I 12:16:05.186 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,185 DEBUG Request 6CDEEF07 Native:debug:58 - Getting entity of kind DAOJob with key DAOJob(5351674944159744)
I 12:16:05.196 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,195 DEBUG Request 6CDEEF07 Retrieve:debug:58 - Fetching object "com.eurekaapp.server.dao.mappedobjects.DAOJob@4adf6a" (id=5351674944159744) fields [acceptStatus,check1,check2,check3,check4,check5,collectionAddress,companyID,containerCode,customerName,customerref,deliveryLatitude,deliveryLongitude,deliveryaddress,deliverytime,enumStatus,groupID,instructions,jobType,jobTypeID,key,lastmodified,localID,notes,parsingSuccessfull,quantity1,quantity2,quantity3,quantity4,ref1,ref2,ref3,ref4,ref5,required_ItemCount,required_Note,required_POD,required_Signature,required_SignatureName,trailerCode,uniqueField,userID,vehicleCode,weight]
I 12:16:05.197 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,196 DEBUG Request 6CDEEF07 Retrieve:debug:58 - Object "com.eurekaapp.server.dao.mappedobjects.DAOJob@4adf6a" (id="5351674944159744") being retrieved from AppEngine
I 12:16:05.199 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,197 DEBUG Request 6CDEEF07 Persistence:debug:58 - Object "com.eurekaapp.server.dao.mappedobjects.DAOJob@4adf6a" (id="com.eurekaapp.server.dao.mappedobjects.DAOJob:5351674944159744") is having the value in field "deliverytime" replaced by a SCO wrapper
I 12:16:05.200 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,199 DEBUG Request 6CDEEF07 Persistence:debug:58 - Object "com.eurekaapp.server.dao.mappedobjects.DAOJob@4adf6a" (id="com.eurekaapp.server.dao.mappedobjects.DAOJob:5351674944159744") is having the value in field "lastmodified" replaced by a SCO wrapper
I 12:16:05.201 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,200 DEBUG Request 6CDEEF07 Connection:debug:58 - Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@11de9d0 for key=org.datanucleus.ObjectManagerImpl@1456e6b in factory=ConnectionFactory:nontx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@f2b4dc] but owner object closing so closing connection
I 12:16:05.202 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,201 DEBUG Request 6CDEEF07 Connection:debug:58 - Connection removed from the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@11de9d0 for key=org.datanucleus.ObjectManagerImpl@1456e6b in factory=ConnectionFactory:nontx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@f2b4dc]
I 12:16:05.203 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,202 DEBUG Request 6CDEEF07 Persistence:debug:58 - Disconnecting com.eurekaapp.server.dao.mappedobjects.DAOJob@4adf6a from StateManager[pc=com.eurekaapp.server.dao.mappedobjects.DAOJob@4adf6a, lifecycle=P_NONTRANS]
I 12:16:05.204 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,203 DEBUG Request 6CDEEF07 Cache:debug:58 - Object with id="com.eurekaapp.server.dao.mappedobjects.DAOJob:5351674944159744" being removed from Level 1 cache [current cache size = 1]
I 12:16:05.205 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,204 DEBUG Request 6CDEEF07 Cache:debug:58 - Level 1 Cache cleared
I 12:16:05.206 [s~server-test-/17.383086902326406416].<stdout>: 12:16:05,205 DEBUG Request 6CDEEF07 Persistence:debug:58 - Object Manager "org.datanucleus.ObjectManagerImpl@1456e6b" closed

- 任何建议?

1 个答案:

答案 0 :(得分:0)

以上用户Andrei Volgin的评论是正确的。

数据存储区查看器字段仅为float和int类型。我编辑了一个double值,它被存储为Long。

我试图通过更新字段来复制该问题,并且最初它没有复制,因为它是从JDO缓存中获取原始对象。

在GAE上启动新实例 “此请求导致为您的应用程序启动一个新进程,从而导致您的应用程序代码首次加载。因此,此请求可能需要更长时间并且使用的CPU比典型的应用程序请求更多。”

JDO去了我新近更新的对象,我得到了一个java.lang.Long,无法强制转换为java.lang.Double。

底线,不要使用数据存储区查看器更新双值