JDK-6315751 : IllegalStateException while decoding the body if it has a fault
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 2.0
  • Priority: P1
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2005-08-25
  • Updated: 2012-06-08
  • Resolved: 2005-11-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b60Fixed
Description
When the soap body has fault, while decoding the body, it throws Illegal;StateException.
Its trying to de-serialize this soap message:
<?xml version="1.0" ?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Receiver</faultcode><faultstring>Person Not Found</faultstring><detail><PersonNotFoundException xmlns="http://example.com/auctiontraq/schemas/doclit"><Name><fname>Foo</fname><lname>Bar</lname></Name><ExMessage>No Person found with this Name</ExMessage><ExMessage>Please try again</ExMessage></PersonNotFoundException></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

Here is the stacktrace.

     [java] java.lang.IllegalStateException: Current state END_ELEMENT is not among the statesCHARACTERS, COMMENT, CDATA, SPACE, ENTITY_REFERENCE, DTD valid for getText() 
     [java] 	at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.getText(XMLStreamReaderImpl.java:967)
     [java] 	at com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.decodeFault(SOAPXMLDecoder.java:254)
     [java] 	at com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBodyContent(SOAPDecoder.java:247)
     [java] 	at com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBody(SOAPDecoder.java:231)
     [java] 	at com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.decodeBody(SOAPXMLDecoder.java:128)
     [java] 	at com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeEnvelope(SOAPDecoder.java:164)
     [java] 	at com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.toInternalMessage(SOAPXMLDecoder.java:191)
     [java] 	at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:357)
     [java] 	at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.doSend(SOAPMessageDispatcher.java:183)
     [java] 	at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.send(SOAPMessageDispatcher.java:93)
     [java] 	at com.sun.xml.ws.encoding.soap.internal.DelegateBase.send(DelegateBase.java:73)
     [java] 	at com.sun.xml.ws.client.EndpointIFInvocationHandler.implementSEIMethod(EndpointIFInvocationHandler.java:161)
     [java] 	at com.sun.xml.ws.client.EndpointIFInvocationHandler.invoke(EndpointIFInvocationHandler.java:94)
     [java] 	at $Proxy25.getPersonByNamePO1(Unknown Source)
     [java] 	at auctiontraq.at_wsdl_doclit.client.sync.AuctionTraqStaticClient4.invokeGetPersonByName_PO1(AuctionTraqStaticClient4.java:181)
     [java] 	at auctiontraq.at_wsdl_doclit.client.AuctionTraqDriver.runStaticClient(AuctionTraqDriver.java:163)
     [java] 	at auctiontraq.at_wsdl_doclit.client.AuctionTraqDriver.doIt(AuctionTraqDriver.java:63)
     [java] 	at auctiontraq.at_wsdl_doclit.client.AuctionTraqDriver.main(AuctionTraqDriver.java:19)
     [java] java.lang.NullPointerException
     [java] 	at com.sun.xml.ws.encoding.soap.ClientEncoderDecoder.toMessageInfo(ClientEncoderDecoder.java:62)
     [java] 	at com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.toMessageInfo(SOAPXMLDecoder.java:139)
     [java] 	at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:361)
     [java] 	at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.doSend(SOAPMessageDispatcher.java:183)
     [java] 	at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.send(SOAPMessageDispatcher.java:93)
     [java] 	at com.sun.xml.ws.encoding.soap.internal.DelegateBase.send(DelegateBase.java:73)
     [java] 	at com.sun.xml.ws.client.EndpointIFInvocationHandler.implementSEIMethod(EndpointIFInvocationHandler.java:161)
     [java] 	at com.sun.xml.ws.client.EndpointIFInvocationHandler.invoke(EndpointIFInvocationHandler.java:94)
     [java] 	at $Proxy25.getPersonByNamePO1(Unknown Source)
     [java] 	at auctiontraq.at_wsdl_doclit.client.sync.AuctionTraqStaticClient4.invokeGetPersonByName_PO1(AuctionTraqStaticClient4.java:181)
     [java] 	at auctiontraq.at_wsdl_doclit.client.AuctionTraqDriver.runStaticClient(AuctionTraqDriver.java:163)
     [java] 	at auctiontraq.at_wsdl_doclit.client.AuctionTraqDriver.doIt(AuctionTraqDriver.java:63)
     [java] 	at auctiontraq.at_wsdl_doclit.client.AuctionTraqDriver.main(AuctionTraqDriver.java:19)

Comments
EVALUATION There was small problem in XMLStreamReaderImpl.isWhiteSpace() implementation. Fix has been committed to JAXP workspace at java.net.
2005-10-27

EVALUATION This is not a bug. Given test case is wrong ! It was pain to look at the big test provided :-) Note that in the test case, following call XMLStreamReaderUtil.nextElementContent(reader); will return if parser encounters either END_DOCUMENT, START_ELEMENT, END_ELEMENT or CHARACTERS. For the given XML file, since there is a new line "\n" character after <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> It returns CHARACTERS event. Next call in the test case is XMLStreamReaderUtil.verifyReaderState(reader, START_ELEMENT); which expects START_ELEMENT state expecting that there can't be any CHARACTERS event after Evelope element and it calls getName() and parsers rightly throws exception. Please check the test case.
2005-10-21

EVALUATION I am attaching a small program which will show the difference between running with Tiger and running with Mustang. Changing the category to jaxp so that they can look into this problem. /home/bhakti/must-test %which java /java/re/jdk/1.5.0_01/archive/fcs/binaries/solaris-sparc/bin/java /home/bhakti/must-test %java -fullversion java full version "1.5.0_01-b08" /home/bhakti/must-test %echo $CLASSPATH sjsxp.jar:jsr173_1.0_api.jar:. /home/bhakti/must-test %java Test1 readercom.sun.xml.stream.XMLReaderImpl Got state START_DOCUMENT Got state START_ELEMENT Got tag {http://schemas.xmlsoap.org/soap/envelope/}Envelope Got state START_ELEMENT Got tag {http://schemas.xmlsoap.org/soap/envelope/}Body Got state START_ELEMENT Got tag {http://schemas.xmlsoap.org/soap/envelope/}Fault Got state START_ELEMENT Got tag faultcode tokensoapenv:Receiver Got state END_ELEMENT Got tag faultcode Got state START_ELEMENT Got tag faultstring FaulStringPerson Not Found Got state END_ELEMENT Got tag faultstring Running with Mustang ==================== /home/bhakti/must-test %which java /java/re/jdk/1.6.0/latest/binaries/solaris-sparc/bin//java /home/bhakti/must-test %java -fullversion /home/bhakti/must-test %java Test1 readercom.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl Got state START_DOCUMENT Got state START_ELEMENT Got tag {http://schemas.xmlsoap.org/soap/envelope/}Envelope Got state START_ELEMENT Got tag {http://schemas.xmlsoap.org/soap/envelope/}Body Got state START_ELEMENT Got tag {http://schemas.xmlsoap.org/soap/envelope/}Fault Got state START_ELEMENT Got tag faultcode Exception in thread "main" java.lang.IllegalStateException: Current state END_ELEMENT is not among the statesCHARACTERS, COMMENT, CDATA, SPACE, ENTITY_REFERENCE, DTD valid for getText() at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.getText(XMLStreamReaderImpl.java:968) at Test1.main(Test1.java:44)
2005-10-14

EVALUATION This test works fine with RI and fails only with Mustang. Rama suspects there is a problem with JAXP that might be causing this to fail in Mustang build only. Thus I'm assigning this bug to Bhakti.
2005-10-14