David.Turing's blog

 

从java.lang.UnsupportedOperationException看WebLogic WS*协议栈的变迁

之前,有些朋友从开源的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中%BEA_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

posted on 2008-07-11 08:29 david.turing 阅读(5609) 评论(4)  编辑  收藏 所属分类: SOA/WebService

评论

# re: 从java.lang.UnsupportedOperationException看WebLogic WS*协议栈的变迁 2008-08-11 07:54 lansir

主持人,还有相应的实战经验的实地演讲么?要是在广州开多几次有多好啊。  回复  更多评论   

# re: 从java.lang.UnsupportedOperationException看WebLogic WS*协议栈的变迁[未登录] 2008-08-20 13:46 alang

黄呀,水平太牛了.现在还在BEA吗?有空可以加我的MSN:alang2000@live.cn  回复  更多评论   

# re: 从java.lang.UnsupportedOperationException看WebLogic WS*协议栈的变迁 2008-08-20 20:36 鬼怪

如果加到:WebLogic 9、10的启动脚本上?

#!/bin/sh

# WARNING: This file is created by the Configuration Wizard.
# Any changes to this script may be lost when adding extensions to this configuration.

DOMAIN_HOME="C:/bea/user_projects/domains/base_domain"

${DOMAIN_HOME}/bin/startWebLogic.sh $*


呵呵,不知道对不对?  回复  更多评论   

# re: 从java.lang.UnsupportedOperationException看WebLogic WS*协议栈的变迁 2009-10-14 15:00 nesta

请问怎么把
-Djavax.xml.soap.MessageFactory=weblogic.webservice.core.soap.MessageFactoryImpl -Djavax.xml.soap.SOAPFactory=weblogic.webservice.core.soap.SOAPFactoryImpl
加入启动里,加在那个地方呢?  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(110)

我参与的团队

随笔分类(126)

随笔档案(155)

文章分类(9)

文章档案(19)

相册

搜索

积分与排名

最新随笔

最新评论

阅读排行榜

评论排行榜