JAX-RPC处理程序发生异常 [英] Exception occurs with JAX-RPC handler

查看:115
本文介绍了JAX-RPC处理程序发生异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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



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

 < ;处理> 
<处理程序名称>我的消息处理程序< /处理程序名称>
< 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);
返回true;
}
...
}

这实际上会产生三个我的日志记录中有异常(具有完全相同的时间戳)。由于长度的原因,我只包含一部分。

 日志级别警告
记录器javax.enterprise.system.container.web
消息ID preWebHandlerError java。 lang.ClassCastException
完整消息com.sun.xml.messaging.saaj.soap.impl.TextImpl无法在
com.sun.xml.rpc.server中转换为javax.xml.soap.SOAPElement。 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:
com.sun.enterprise.webservice.JAXRPCServlet.doPost(JAXRPCServlet.java:119)at
javax.servlet.http.HttpServlet.service(HttpServlet.java:738)at
...

日志级别SEVERE
Logger com.sun.xml.rpc.server
消息ID com.sun.xml.messaging.saaj.soap.impl.TextImpl无法转换为javax.xml.soap.SOAPBodyElement java.lang.ClassCastException
完成消息com.sun.xml.messaging.saaj.soap.impl.TextImpl无法转换为位于$的javax.xml.soap.SOAPBodyElement b $ b 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
...

日志级别SEVERE
Logger com.sun.xml.rpc.server
消息ID JAXRPCTIE01
处理请求时完成消息捕获异常:java.lang.ClassCastException:com.sun.xml.messaging。 saaj.soap.impl.TextImpl无法转换为javax.xml.soap.SOAPBodyElement java.lang.ClassCastException:com.sun.xml.messaging.saaj.soap.impl.TextImpl无法转换为javax.xml.soap.SOAPBodyElement
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) b $ b

任何人都有一些想法来解决这个问题吗? 你的库处于不兼容的状态。

>

重要的部分是:java.lang.ClassCastException:

com.sun.xml.messaging.saaj.soap.impl .TextImp l无法转换为javax.xml.soap.SOAPBodyElement



这意味着要么jre包含javax.xml的实现(即jre 6.0),或者glassfish包含一个新的实现的运行时,或者包含一个不兼容的库。



有人破坏了1.4 - > 1.5之间的xml实现。我建议在javax.xml.soap.SOAPBodyElement的所有jar中进行搜索。你会发现不兼容的重复项(例如xml-beans stax或其他)。


I have some SOAP webservices build with JAX-RPC. These work fine. But as soon as I add a handler, I get an exception. When the binding is removed from the webservices.xml, everything works fine again.

The weird thing is, the handler itself isn't included in the stacktrace of the exception. I also noticed, the init and getHeaders methods of the handler are called, before the exception is raised.

The handler is added to webservices.xml with the following xml:

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

The handler itself is just a stub, generated by the IDE from the interface, so I won't include the whole implementation:

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

This actually generates three exceptions in my logging (with the exact same timestamp). Because of the length, I only include a portion.

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
    ...

Anyone got some ideas to solve this?

解决方案

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).

这篇关于JAX-RPC处理程序发生异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆