weblogic 9.2.0's stax seems not working with xfire 1.2.4

Problem Description:

Tomcat 5.5.17 is used as the web service host and weblogic 9.2.0 is used as the web service client.

If the return value of ws methods is a complex object, an exception will be thrown:

java 代码
  1. Caused by: java.lang.UnsupportedOperationException   
  2.     at weblogic.xml.stax.XMLStreamReaderBase.getTextCharacters(XMLStreamReaderBase.java:487)   
  3.     at org.codehaus.xfire.util.stax.DepthXMLStreamReader.getTextCharacters(DepthXMLStreamReader.java:180)   
  4.     at org.codehaus.xfire.util.stax.DepthXMLStreamReader.getTextCharacters(DepthXMLStreamReader.java:180)   
  5.     at org.codehaus.xfire.aegis.type.basic.Base64Type.readObject(Base64Type.java:71)   
  6.     at org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:159)   
  7.     at org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:162)   
  8.     at org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206)   
  9.     at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:50)   
  10.     at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)   
  11.     at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)   
  12.     at org.codehaus.xfire.client.Client.onReceive(Client.java:382)  

 

Thoughts:

According to the stacktrace, it seems weblogic's default xml stax parser doesn't work with xfire 1.2.4 if the method's return value is complex objects. Am thinking to replace the default parser with the one from xfire's library. But how?

Solution:

Set "prefer-web-inf-classes" to true.

xml 代码
  1. <container-descriptor>  
  2.     <prefer-web-inf-classes>true<!---->prefer-web-inf-classes>  
  3. <!---->container-descriptor>  

Based on the document:

If true, classes located in the WEB-INF directory of a web-app will be loaded in preference to classes loaded in the application or system classloader. Defaults to false. Value specified via console will be given precedence over this setting.

Problem solved!

你可能感兴趣的:(java,Web,weblogic,servlet,360)