EJB 远程方法中不匹配的序列化 UID - java.util.date & DBTimestamp

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11555224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 05:33:16  来源:igfitidea点击:

Mismatched serialization UIDs in EJB Remote Method - java.util.date & DBTimestamp

javaserializationdb2websphereejb-3.0

提问by J Barclay

I have a java web application that is deployed in two EARs - one for the UI tier (contains a WAR module) and one for the business tier (contains an EJB module). Both tiers are deployed to WebSphere Application Server 7. The tiers are connected via EJB 3.0 stateless session beans. The beans are looked up via JNDI.

我有一个部署在两个 EAR 中的 Java Web 应用程序 - 一个用于 UI 层(包含一个 WAR 模块),一个用于业务层(包含一个 EJB 模块)。两个层都部署到 WebSphere Application Server 7。这些层通过 EJB 3.0 无状态会话 bean 连接。通过 JNDI 查找 bean。

We use Hibernate for persistence, and a DB2 database.

我们使用 Hibernate 进行持久化,并使用 DB2 数据库。

When the remote EJB call is returned, the following error occurs on the client side:

远程EJB调用返回时,客户端出现如下错误:

java.rmi.MarshalException: CORBA MARSHAL 0x4942f896 No; nested exception is: 
    org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : Mismatched serialization UIDs : Source (RepId RMI:java.util.Date:AC117E28FE36587A:686A81014B597419) = 686A81014B597419 whereas Target (RepId RMI:com.ibm.db2.jcc.DBTimestamp:AA774DBE96ECCE99:7AFCE1FB570D419C) = 7AFCE1FB570D419C  vmcid: IBM  minor code: 896  completed: No

The java.util.Datefield on the object is being returned from Hibernate as a com.ibm.db2.jcc.DBTimestampfield, which extends java.sql.Timestampwhich extends java.util.Date. As it is a subclass of java.util.Dateand is serializable, shouldn't this be handled?

java.util.Date对象上字段被从休眠返回作为com.ibm.db2.jcc.DBTimestamp字段,其延伸java.sql.Timestamp,其延伸java.util.Date。因为它是 的子类java.util.Date并且是可序列化的,所以不应该处理吗?

I've spoken to a more experience person who has said the likely cause is that the JVM version or DBTimestampclass version is different between the web and business tier WAS servers. Both servers have the same JVM, WAS, and JAR version.

我曾与一位更有经验的人交谈过,他说可能的原因是DBTimestampWeb 和业务层 WAS 服务器之间的JVM 版本或类版本不同。两台服务器具有相同的 JVM、WAS 和 JAR 版本。

I also have a local WAS 7 server, where both tiers are deployed to the same server. The EJBs are still resolved remotely via a JNDI call to localhost. The application works fine on my local server. The only difference I'm aware of is a different micro-version of WAS, as well as deploying both tiers to the same server.

我还有一个本地 WAS 7 服务器,其中两个层都部署到同一台服务器上。EJB 仍然通过对 localhost 的 JNDI 调用远程解析。该应用程序在我的本地服务器上运行良好。我知道的唯一区别是 WAS 的不同微版本,以及将两个层部署到同一台服务器。

What is the cause of the problem? Is it that the DBTimestampclass can't be found on the web tier, or that the version of the class is different? Or is it an issue with polymorphism, or something else entirely?

问题的原因是什么?是DBTimestamp不是web层找不到类,还是类的版本不一样?或者它是多态性的问题,还是完全其他的问题?

Aside from an answer, I'd also appreciate any advice on what debugging to try - I'm out of ideas.

除了答案,我也很感激任何关于尝试调试的建议 - 我没有想法。

采纳答案by J Barclay

I have managed to 'fix' the problem by packaging up the relevant DB2 driver JAR in the web tier EAR.

通过在 Web 层 EAR 中打包相关的 DB2 驱动程序 JAR,我设法“修复”了这个问题。

The cause of the problem is therefore that the class was not available on the classpath of the web tier. I will need to investigate the setup of the environment to figure out why it's not available, but at least the problem is clear now.

因此,问题的原因是该类在 Web 层的类路径上不可用。我需要调查环境的设置以找出它不可用的原因,但至少现在问题已经很清楚了。