[jboss-user] [JBossWS] - IndexOutOfBoundsException when transforming into SAAJ SOAPBo

poutsma do-not-reply at jboss.com
Tue Jul 11 10:45:11 EDT 2006


Hi,

The following piece of code throws an IndexOutOfBoundsException in org.jboss.ws.soap.NodeImpl.getFirstChild:


  | import org.w3c.dom.Document;
  | import org.w3c.dom.Element;
  | 
  | import javax.xml.parsers.DocumentBuilderFactory;
  | import javax.xml.soap.MessageFactory;
  | import javax.xml.soap.SOAPBody;
  | import javax.xml.soap.SOAPMessage;
  | import javax.xml.transform.Transformer;
  | import javax.xml.transform.TransformerFactory;
  | import javax.xml.transform.dom.DOMResult;
  | import javax.xml.transform.dom.DOMSource;
  | import javax.xml.transform.stream.StreamResult;
  | 
  | public class SaajIssue {
  | 
  |     public static void main(String[] args) throws Exception {
  |         MessageFactory messageFactory = MessageFactory.newInstance();
  |         SOAPMessage soapMessage = messageFactory.createMessage();
  |         Transformer transformer = TransformerFactory.newInstance().newTransformer();
  |         Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  |         Element root = document.createElementNS("http://test.com", "root");
  |         document.appendChild(root);
  |         Element child = document.createElementNS("http://test.com", "child");
  |         root.appendChild(child);
  |         SOAPBody body = soapMessage.getSOAPBody();
  |         transformer.transform(new DOMSource(document), new DOMResult(body));
  |         // Next line throws an IndexOutOfBoundsException
  |         transformer.transform(new DOMSource(body), new StreamResult(System.out));
  |     }
  | }
  | 

This is the stacktrace:


  | Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  | 	at java.util.ArrayList.RangeCheck(ArrayList.java:546)
  | 	at java.util.ArrayList.get(ArrayList.java:321)
  | 	at org.jboss.ws.soap.NodeImpl.getFirstChild(NodeImpl.java:311)
  | 	at org.jboss.ws.soap.SOAPContentElement.getFirstChild(SOAPContentElement.java:746)
  | 	at org.apache.xml.serializer.TreeWalker.traverse(TreeWalker.java:145)
  | 	at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:389)
  | 	at SaajIssue.main(SaajIssue.java:36)
  | 

After some investigation, it appears that the root element is imported correctly, but the child element is not. To be more precise: it is imported into the internal domNode of NodeImpl, but not the soapChildren list.

SUN's reference implementation of SAAJ does not throw this exception, so it appears this is a bug in the JBoss SAAJ implementation. Am I correct?

Thanks,

Arjen Poutsma

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957021#3957021

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957021



More information about the jboss-user mailing list