之前,有些朋友从开源的ws*应用(比如说axis、cxf)迁移到weblogic 9、10上,经常遇到类似下面的异常:
java.lang.unsupportedoperationexception: this
class
does not support saaj
1.3
at weblogic.webservice.core.soap.soapelementimpl.getelementqname(soapelementimpl.java:
651
)
at org.springframework.ws.soap.saaj.saaj13implementation.getname(saaj13implementation.java:
67
)
at org.springframework.ws.soap.saaj.saajsoapenvelope.getbody(saajsoapenvelope.java:
49
)
at org.springframework.ws.soap.abstractsoapmessage.getsoapbody(abstractsoapmessage.java:
35
)
at org.springframework.ws.soap.abstractsoapmessage.getpayloadresult(abstractsoapmessage.java:
56
)
这有一些历史因素在内,weblogic 8.1的webservice协议栈,包含在weblogic.jar中。
soap栈的全部实现,都在weblogic.webservice.core.soap.* 这个package中。
进入了java5的时代后,jws依靠annotation方式,已经彻底改变webservice编程的外观,于是,随之而来的是,基于java5的weblogic 9/10,基本上使用sun jws方式实现web services,且weblogic开始兼容新的ws* api,weblogic的做法是deprecated以前的ws api(weblogic.webservice.core.soap.*),但为了8.1应用升级的兼容性考虑,用户依然使用较旧的包。
比如上述的notsupport异常,在默认的weblogic 9、10中�a_home%\modules\com.bea.core.weblogic.saaj_1.0.1.0.jar其实是support的。
对weblogic 8.1老用户来说,他们的ws*应用无需重新编码即可运行在weblogic 9.2,此时默认使用老的协议栈【weblogic.webservice.core.soap.*】
对weblogic 9.2新用户来说,他们也可以使用老协议栈,也可以使用新的协议栈,使用【weblogic.xml.saaj.*】
针对上述的notsupport异常,有两种方式可以让应用使用新的api实现:
system.setproperty("javax.xml.soap.messagefactory", "weblogic.xml.saaj.messagefactoryimpl");
-djavax.xml.soap.messagefactory=weblogic.xml.saaj.messagefactoryimpl
java.lang.unsupportedoperationexception: this
class
does not support
saaj
1.1
the actual
class
/
method in question is javax.xml.soap.text.iscomment(), which
appears to be implemented by
weblogic.webservice.core.soap.soaptextelement.iscomment().
stack trace is as follows:
demoservlet received an unexpected exception:
java.lang.unsupportedoperationexception: this
class
does not support saaj
1.1
java.lang.unsupportedoperationexception: this
class
does not support saaj
1.1
at
weblogic.webservice.core.soap.soaptextelement.iscomment(soaptextelement.java:
43
)
at
com.company.demo.servlet.demoservlet.treewalk(demoservlet.java:
209
)
at
com.company.demo.servlet.demoservlet.treewalk(demoservlet.java:
225
)
at
com.company.demo.servlet.demoservlet.treewalk(demoservlet.java:
225
)
at
com.company.demo.servlet.demoservlet.treewalk(demoservlet.java:
225
)
at
com.company.demo.servlet.demoservlet.treewalk(demoservlet.java:
225
)
at
com.company.demo.servlet.demoservlet.treewalk(demoservlet.java:
225
)
at
com.company.demo.servlet.demoservlet.treewalk(demoservlet.java:
225
)
at
com.company.demo.servlet.demoservlet.treewalk(demoservlet.java:
225
)
at
com.company.demo.servlet.demoservlet.dogetorpost(demoservlet.java:
119
)
at com.company.demo.servlet.demoservlet.doget(demoservlet.java:
44
)
at javax.servlet.http.httpservlet.service(httpservlet.java:
743
)
at javax.servlet.http.httpservlet.service(httpservlet.java:
856
)
at
weblogic.servlet.internal.stubsecurityhelper$servletserviceaction.run(stubsecurityhelper.java:
225
)
at
weblogic.servlet.internal.stubsecurityhelper.invokeservlet(stubsecurityhelper.java:
127
)
at
weblogic.servlet.internal.servletstubimpl.execute(servletstubimpl.java:
283
)
at
weblogic.servlet.internal.servletstubimpl.execute(servletstubimpl.java:
175
)
at
weblogic.servlet.internal.webappservletcontext$servletinvocationaction.run(webappservletcontext.java:
3214
)
at
weblogic.security.acl.internal.authenticatedsubject.doas(authenticatedsubject.java:
321
)
at
weblogic.security.service.securitymanager.runas(securitymanager.java:
121
)
at
weblogic.servlet.internal.webappservletcontext.securedexecute(webappservletcontext.java:
1983
)
at
weblogic.servlet.internal.webappservletcontext.execute(webappservletcontext.java:
1890
)
at
weblogic.servlet.internal.servletrequestimpl.run(servletrequestimpl.java:
1344
)
at weblogic.work.executethread.execute(executethread.java:
209
)
at weblogic.work.executethread.run(executethread.java:
181
)
很好,因为它们使用了更多的api,这些api在weblogic的老协议栈【weblogic.webservice.core.soap.*】中没有被支持,使用新的即可。
我一般在重启weblogic的时候,在startweblogic.sh脚本中加入:
-djavax.xml.soap.messagefactory=weblogic.webservice.core.soap.messagefactoryimpl -djavax.xml.soap.soapfactory=weblogic.webservice.core.soap.soapfactoryimpl