【问题标题】:Mule ESB Serialization incompatible errorMule ESB 序列化不兼容错误
【发布时间】:2017-06-04 16:58:17
【问题描述】:

从 Mule 3.2.2 向 Mule 3.7.1 进行服务调用时,我收到以下异常。

虽然 org.mule.transformer.types.SimpleDataType 类的串行器在两个运行时都不同,但我不知道为什么这是一个问题。因为 Object 无论如何都被序列化为 SOAP 请求。

感谢任何帮助!

Mule 3.2.2 运行时中的客户端代码:

<cxf:jaxws-client serviceClass="org.test" doc:name="SOAP"  >
<cxf:ws-security>
    <cxf:ws-config>
        <cxf:property key="action" value="UsernameToken"/>
        <cxf:property key="user" value="test"/>
        <cxf:property key="passwordCallbackRef" value-ref="passwordCallbackHandler" />
        <cxf:property key="passwordType" value="PasswordText" />
    </cxf:ws-config>
</cxf:ws-security>

例外

 Message               : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=https://testlb:17105/service/1.0/, connector=HttpsConnector
{
  name=connector.https.mule.default
  lifecycle=start
  this=60de93b4
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[https]
  serviceOverrides=<none>
}
,  name='endpoint.https.testlb.17105.service.1.0', mep=REQUEST_RESPONSE, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=60000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: PostMethod
Code                  : MULE_ERROR-42999
--------------------------------------------------------------------------------
Exception stack is:
1. org.mule.transformer.types.SimpleDataType; local class incompatible: stream classdesc serialVersionUID = 734974842501135657, local class serialVersionUID = 6394740184248968880 (java.io.InvalidClassException)
  java.io.ObjectStreamClass:617 (null)
2. java.io.InvalidClassException: org.mule.transformer.types.SimpleDataType; local class incompatible: stream classdesc serialVersionUID = 734974842501135657, local class serialVersionUID = 6394740184248968880 (org.apache.commons.lang.SerializationException)
  org.mule.util.SerializationUtils:89 (null)
3. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=https://testlb:17105/service/1.0/, connector=HttpsConnector
{
  name=connector.https.mule.default
  lifecycle=start
  this=60de93b4
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[https]
  serviceOverrides=<none>
}
,  name='endpoint.https.testlb.17105.service.1.0', mep=REQUEST_RESPONSE, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=60000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: PostMethod (org.mule.api.transport.DispatchException)
  org.mule.transport.AbstractMessageDispatcher:109 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.io.InvalidClassException: org.mule.transformer.types.SimpleDataType; local class incompatible: stream classdesc serialVersionUID = 734974842501135657, local class serialVersionUID = 6394740184248968880
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:617)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1622)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

【问题讨论】:

    标签: serialization soap https mule cxf


    【解决方案1】:

    此问题已解决!

    如 Mule documentation 中所述,来自 3.7.1 运行时的会话变量被包装到 SimpleDataType.class 中,并且这个序列化的 Base64 编码字符串作为 MULE_SESSION 标头传递到另一个运行时。当其他Runtime反序列化这个header时,由于类版本不同,会报错。

    通过将此 NullSessionHandler 传递给 HTTP 连接器来解决此问题,因为我们并不关心该标头。

    <service-overrides sessionHandler="org.mule.session.NullSessionHandler"/>
    

    【讨论】:

      【解决方案2】:

      你完全正确。这根本不应该是一个问题。然而,Java 有序列化的最佳实践——不要混合不兼容的类,它们看起来完全相同的 serialVersionUID 属性被添加到类中。通常开发人员不会注意它,但当他们这样做时,这意味着类确实不同。

      这实际上意味着您不能使用序列化来传递数据。你的案例就是很好的例子。

      要解决这个问题,你必须摆脱序列化 - 这个类在这两个版本的 Mule 中是不同的。

      另一种选择是用更稳定的东西代替类。甚至创建自己的 SimpleDataType。

      或者您可以使用 Mule 支持打开票证以解决版本不兼容问题。但是我怀疑他们是否会出于同样的原因修复它 - 类是不同的,这是它们不同的充分理由。

      【讨论】:

      • 感谢您的调查。我没有进行任何序列化,但我相信 Mule 正在内部对其进行序列化,所以我不知道如何摆脱它。我也不确定替换 Mule 课程是个好主意。我可能会请骡建议。再次感谢!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-05
      • 2019-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多