0

我有一些使用 JAX-RPC 构建的 SOAP Web 服务。这些工作正常。但是一旦我添加了一个处理程序,我就会得到一个异常。从 webservices.xml 中删除绑定后,一切都会再次正常运行。

奇怪的是,处理程序本身不包含在异常的堆栈跟踪中。我还注意到,在引发异常之前调用了处理程序的init和方法。getHeaders

使用以下 xml 将处理程序添加到 webservices.xml:

<handler>
  <handler-name>My Message Handler</handler-name>
  <handler-class>kpn.MyMessageHandler</handler-class>
</handler>

处理程序本身只是一个存根,由 IDE 从接口生成,所以我不会包括整个实现:

public class MyMessageHandler implements javax.xml.rpc.handler.Handler {
  @Override
  public boolean handleRequest(MessageContext context) {
    System.out.println("handel-Request");
    return true;
  }
  ...
}

这实际上在我的日志记录中生成了三个异常(具有完全相同的时间戳)。由于篇幅关系,我只包括一部分。

Log Level  WARNING 
Logger  javax.enterprise.system.container.web 
Message ID  preWebHandlerError java.lang.ClassCastException 
Complete Message  com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPElement at
    com.sun.xml.rpc.server.StreamingHandler.getOpcodeForRequestMessage(StreamingHandler.java:657) at
    com.sun.enterprise.webservice.WsUtil.getInvMethod(WsUtil.java:1277) at
    com.sun.enterprise.webservice.ServletPreHandler.handleRequest(ServletPreHandler.java:86) at
    com.sun.xml.rpc.client.HandlerChainImpl.handleRequest(HandlerChainImpl.java:103) at
    com.sun.xml.rpc.server.StreamingHandler.callRequestHandlers(StreamingHandler.java:962) at
    com.sun.xml.rpc.server.StreamingHandler.preHandlingHook(StreamingHandler.java:868) at
    kpn.kpc.SOAPKPCReadCustomerClassification_v01PortType_Tie.preHandlingHook(SOAPKPCReadCustomerClassification_v01PortType_Tie.java:242) at
    com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:127) at
    com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate.java:467) at
    com.sun.enterprise.webservice.JAXRPCServlet.doPost(JAXRPCServlet.java:119) at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:738) at
    ...

Log Level  SEVERE 
Logger  com.sun.xml.rpc.server 
Message ID  com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement java.lang.ClassCastException 
Complete Message  com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement at
    com.sun.enterprise.webservice.WsUtil.throwSOAPFaultException(WsUtil.java:1312) at
    com.sun.enterprise.webservice.WsUtil.throwSOAPFaultException(WsUtil.java:1288) at
    com.sun.enterprise.webservice.ServletPreHandler.handleRequest(ServletPreHandler.java:99) at
    ...

Log Level  SEVERE 
Logger  com.sun.xml.rpc.server 
Message ID  JAXRPCTIE01 
Complete Message  caught exception while handling request: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement at
    com.sun.enterprise.webservice.WsUtil.throwSOAPFaultException(WsUtil.java:1312) at
    com.sun.enterprise.webservice.WsUtil.throwSOAPFaultException(WsUtil.java:1288) at
    com.sun.enterprise.webservice.ServletPreHandler.handleRequest(ServletPreHandler.java:99) at
    ...

有人有解决这个问题的想法吗?

4

1 回答 1

2

Your libraries are in an incompatible state.

The important part is: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement

This means that either the jre contains an implementation for javax.xml (ie jre 6.0), or the glassfish contains a runtime with a newer implementation or you include a library that is not compatible.

Someone broke the xml implementation between 1.4 -> 1.5. I suggest a search in all the jars for javax.xml.soap.SOAPBodyElement. You'll find duplicates which are not compatible (eg xml-beans stax or something).

于 2009-02-13T13:39:36.770 回答