Uploaded image for project: 'JBoss Web Services'
  1. JBoss Web Services
  2. JBWS-2526

org.jboss.ws.core.soap.TextImpl does not implement org.w3c.dom.Comment

XMLWordPrintable

      I have encountered a bug with JBossWS in a LogicalHandler that I have written. This handler serializes the Payload to a String using ordinary Transformer API. When the Payload contains an XML comment, a ClassCastException is thrown from within Xalan's TreeWalker class. TreeWalker casts the node to an org.w3c.dom.Comment.

      Here's the partial source to the handler:

      public boolean handleMessage(LogicalMessageContext context) {
      if (JAXWSUtil.isInbound(context))

      { LogicalMessage message = context.getMessage(); Source payload = message.getPayload(); context.put("com.blah.blah.inbound.message.payload", payload); }

      return true;
      }

      public boolean handleFault(LogicalMessageContext context)

      { LogicalMessage message = context.getMessage(); Source outboundPayload = message.getPayload(); String outboundXML = JAXWSUtil.toString(outboundPayload); Source inboundPayload = (Source) context.get("com.blah.blah.inbound.message.payload"); String inboundXML = JAXWSUtil.toString(inboundPayload); // throws ClassCastException sendAlarm("The following fault occurred:\n\n" + outboundXML + "\n\nRequest:\n" + inboundXML); return true; }

      JAXWSUtil uses Transformer API like so:

      public static String toString(Source payload) {
      TransformerFactory factory = getTransformerFactory();
      Transformer transformer = factory.newTransformer();
      transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
      transformer.setOutputProperty("

      {http://xml.apache.org/xalan}

      indent-amount", "2");
      StringWriter output = new StringWriter();
      StreamResult result = new StreamResult(output);
      transformer.transform(payload, result);
      return output.toString();
      }

      Here's the ClassCastException stacktrace:

      java.lang.ClassCastException: org.jboss.ws.core.soap.TextImpl
      at org.apache.xml.serializer.TreeWalker.startNode(TreeWalker.java:287)
      at org.apache.xml.serializer.TreeWalker.traverse(TreeWalker.java:143)
      at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:389)
      at com.xo.nextgen.hvodwebservice.util.xslt.TransformerWrapper.transform(TransformerWrapper.java:42)
      at com.xo.nextgen.hvodwebservice.util.JAXWSUtil.toString(JAXWSUtil.java:272)
      at com.xo.nextgen.hvodwebservice.wsdl.handler.FaultNotificationHandler.handleFault(FaultNotificationHandler.java:147)
      at com.xo.nextgen.hvodwebservice.wsdl.handler.AbstractLogicalHandler.handleFault(AbstractLogicalHandler.java:1)
      at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleFault(HandlerChainExecutor.java:318)
      at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleFault(HandlerChainExecutor.java:216)
      at org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS.callFaultHandlerChain(HandlerDelegateJAXWS.java:131)
      at org.jboss.ws.core.server.ServiceEndpointInvoker.callFaultHandlerChain(ServiceEndpointInvoker.java:140)
      at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:284)
      at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:474)

      Here is the code to Xalan-2.7.0 TreeWalker around line 287:

      switch (node.getNodeType())
      {
      case Node.COMMENT_NODE :
      {
      String data = ((Comment) node).getData(); // throws ClassCastException

      My project had been working with the JAX-WS Reference Implementation under JBoss 4.0 and I am in the process of converting the project to JBossWS so that it may be deployed on JBoss 4.2+. I mention this because I peeked into how the JAX-WS RI dealt with the javax.xml.soap.Text interface and it appears that Sun's SAAJ has distinct TextImpl and CommentImpl classes.

              rhn-support-asoldano Alessio Soldano
              gturner_jira Gerald Turner (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: