soap消息jdk版本问题导致报错

Posted 六楼外的风景

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了soap消息jdk版本问题导致报错相关的知识,希望对你有一定的参考价值。

需求背景:

1.

最近要开放一项融合业务受理接口,什么是融合业务,简单来说就是手机主副卡+宽带混合产品在同一个账户交费;

这就遇到一个问题,就是6层的xml其中5层中是多对多的关系;如下:

xml结构:
---请求信息
	--产品信息(多个)
		--产品类型(多个)
			--构成包信息(多个)
				--元素信息(多个)
					--元素附加属性(多个)
	--账户信息(一个)
		--组合账户信息(多个)
			--托收信息(多个)



对于一般的java系统来说这不是个问题,很易解决,然后把数据按逻辑入库生成即可,但我们系统中用到了tuxedo中间件,这5层中是多对多的关系要通过tuxedo的字段给到我们后台,问题就来了;


fml数组要传这5次的xml数据这种情况我们不是第一次遇到,有比较成熟的转为我们内部的专用的数据构DataBufTux 在c++中是很方便可以像dom4j那个操作这些数据的,但问题就是在一个新的项目中加入原来我们那个套转换算法要先把xml转为soap消息再转为我们内部的DataBufTux ; 


2.环境

测试主机用的是AIX 5.3.0.0  jdk最到只支持到IBM jdk1.6 程序一上来就报如下错,怎么会这样,我本地运行好好的,用的也是jdk1.6  ,这个报错是在string转soap消息时报的

代码:

MessageFactory mf = MessageFactory.newInstance();
SOAPMessage sm=mf.createMessage(null, new ByteArrayInputStream(reqStr.getBytes(Charset.forName("UTF-8"))));
报错:
com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
        at com.sun.xml.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:530)
        at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:319)
        at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:74)
        at com.linkage.iboss.translator.IBSS.wo.SoapUtil.String2Buff(SoapUtil.java:35)
        at com.linkage.iboss.translator.IBSS.wo.MeMixBusinessCheckTranslator.convert2Fml(MeMixBusinessCheckTranslator.java:206)
        at com.linkage.iboss.translator.MessageParser.convertSvcCont2Fml(MessageParser.java:289)
        at com.linkage.iboss.translator.HomeMessageTranslator.convertSvcCont2Fml(HomeMessageTranslator.java:61)
        at com.linkage.iboss.convertor.IBOSSHomeConvertor.porecssReqData(IBOSSHomeConvertor.java:130)
        at com.linkage.uip.processor.ReqDataConvertCMD.execute(ReqDataConvertCMD.java:120)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:166)
        at com.linkage.uip.processor.DefaultChain.execute(Unknown Source)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:166)
        at com.linkage.uip.processor.DefaultChain.execute(Unknown Source)
        at com.linkage.uip.processor.CommonDataProc.process(Unknown Source)
        at com.linkage.uip.receiver.HTTPDataReceiver.doPost(HTTPDataReceiver.java:565)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.NoClassDefFoundError: com.sun.org.apache.xerces.internal.dom.DocumentImpl
...跳过...
com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
        at com.sun.xml.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:530)
        at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:319)
        at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:74)
        at com.linkage.iboss.translator.IBSS.wo.SoapUtil.String2Buff(SoapUtil.java:35)
        at com.linkage.iboss.translator.IBSS.wo.MeMixBusinessCheckTranslator.convert2Fml(MeMixBusinessCheckTranslator.java:206)
        at com.linkage.iboss.translator.MessageParser.convertSvcCont2Fml(MessageParser.java:289)
        at com.linkage.iboss.translator.HomeMessageTranslator.convertSvcCont2Fml(HomeMessageTranslator.java:61)
        at com.linkage.iboss.convertor.IBOSSHomeConvertor.porecssReqData(IBOSSHomeConvertor.java:130)
        at com.linkage.uip.processor.ReqDataConvertCMD.execute(ReqDataConvertCMD.java:120)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:166)
        at com.linkage.uip.processor.DefaultChain.execute(Unknown Source)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:166)
        at com.linkage.uip.processor.DefaultChain.execute(Unknown Source)
        at com.linkage.uip.processor.CommonDataProc.process(Unknown Source)
        at com.linkage.uip.receiver.HTTPDataReceiver.doPost(HTTPDataReceiver.java:565)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.NoClassDefFoundError: com.sun.org.apache.xerces.internal.dom.DocumentImpl
        at java.lang.ClassLoader.defineClassImpl(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:275)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69)
        at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:335)
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:288)
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
        at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
        at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.<init>(SOAPPartImpl.java:113)
        at com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.getSOAPPart(Message1_1Impl.java:90)
        at com.sun.xml.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:410)
        ... 28 more
Caused by: java.lang.ClassNotFoundException: Class bytes found but defineClass()failed for: 'com.sun.org.apache.xerces.internal.dom.DocumentImpl'
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:262)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
        at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
        ... 40 more
Caused by: java.lang.UnsupportedClassVersionError: JVMCFRE003 主要版本错误;类=com/sun/org/apache/xerces/internal/dom/DocumentImpl,偏移量=6
        at java.lang.ClassLoader.defineClassImpl(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:275)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69)
        at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:335)
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:288)
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
        ... 43 more


很明显是运行时抛的java.lang.NoClassDefFoundError ,细看这肯定是jdk版本过低了,有些方法不支持之类的,看下IBM-jdk下jre的lib包rt.jar中是没有com.sun.org.apache.xerces.internal.dom.DocumentImpl相关的类,一对比本地sun的这个rt.jar包,本地的是53M而IBM的是19M,明显是少了不少东西,这个问题,升级个jdk可以轻松解决,但是...........


事实告诉我的想法太天真了,在ibm的jdk版本,aix5.3系统是不支持ibm-jdk7的,要想装ibm-jdk7,必先升组aix系统到6.1以上,这个找ibm小型机的人做也不一定愿意做,再加了这台主机上还有测试+开发的oracle数据库,mydql ,redis等,但不装感觉又不支持,还有什么招,哎心想为什么这个项目要部署在这台主机上呢!!


想了很多办法,替换相关jar包 , 把依赖的jar中的类加放到项目本地的class下,把相关新jar包放到本地项目的lib包下,但是,人家jdk加载过程中是优先加载自已的,认为加载过了就不会再加载我放上去的了............................


然而,升组jdk好像是唯一解决的方法了但在网上看到了一个jdk参数

JVM系统属性 java.endorsed.dirs 

java.endorsed.dirs 包升级替换机制,把相关依据包放到一个目录如 /home/webapp/endorsed 在web启动参数中加入-Djava.endorsed.dirs= /home/webapp/endorsed 

这个居然解决了........!  

后面查了还有个参数也挺有用的

java.ext.dirs 可选包扩展机制


后面就是比较顺利的一 堆业务处理了


以上,望对你们有一定帮助!






















以上是关于soap消息jdk版本问题导致报错的主要内容,如果未能解决你的问题,请参考以下文章

发送soap信息失败是啥意思

项目版本不同导致Eclipse报错问题——关于在JDK1.7环境中,运行JDK1.8环境下编写的项目

HTTP Status 500:报错Unsupported major.minor version 51.0(unable to load class XXX)

记一次项目导入报错经验

WCF - 错误:传出消息的消息版本 (Soap12 (http://www.w3.org/2003/05/soap-envelope)

jdk 版本不一致导致的错误