从DB获取数据时RCP方法中的GWT ClassCastException

时间:2015-03-12 14:02:22

标签: java glassfish-3 gwt-rpc gwt2 application-server


有几次,在glassfish上部署后,我有一个例外:

SEVERE|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=40;_ThreadName=Thread-1;|java.lang.ClassCastException: com.gwt.server.domain.model.OrgUnit cannot be cast to com.gwt.server.domain.model.OrgUnit

OrgUnit是一个简单的JPA实体,而不是在com.gwt.server.domain.model包中发生。

Stackstrace是:

SEVERE|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=40;_ThreadName=Thread-1;|java.lang.ClassCastException: com.gwt.server.domain.model.OrgUnit cannot be cast to com.gwt.server.domain.model.OrgUnit
    at com.gwt.server.service.orgUnit.OrgUnitServiceImpl$1.execute(OrgUnitServiceImpl.java:51)
    at com.gwt.server.service.orgUnit.OrgUnitServiceImpl$1.execute(OrgUnitServiceImpl.java:40)
    at com.gwt.server.service.api.AbstractCommand.invoke(AbstractCommand.java:56)
    at com.gwt.server.service.orgUnit.OrgUnitServiceImpl.findAll(OrgUnitServiceImpl.java:39)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)

我如何解决这个问题? 感谢。

2 个答案:

答案 0 :(得分:1)

一个问题......只是部署¿?如果重新启动Glassfish,它会持续存在问题吗?

看看这个:EclipseLink + JPA Guice Persist and Redeployments ....

而且:https://bugs.eclipse.org/bugs/show_bug.cgi?id=326552

答案 1 :(得分:0)

看起来你有两个不同的JAR在类路径中包含相同的类