Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.8
    • Fix Version/s: None
    • Component/s: jaxb
    • Labels:
      None
    • Environment:

      Windows 7

      Activity

      Hide
      Iaroslav Savytskyi added a comment -

      Will you provide any details?

      Show
      Iaroslav Savytskyi added a comment - Will you provide any details?
      Hide
      kluch added a comment -

      Sorry, I've clicked something wrong.
      Here are the details:

      The following NPE is thrown by calling SOAPMessageContext.getMessage() by handling a message in an instance of SOAPHandler.

      java.lang.NullPointerException
      	at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addNamespaceDeclaration(Unknown Source)
      	at com.sun.xml.ws.api.message.saaj.SaajStaxWriter.writeNamespace(SaajStaxWriter.java:193)
      	at com.sun.xml.ws.util.xml.XMLStreamReaderToXMLStreamWriter.handleStartElement(XMLStreamReaderToXMLStreamWriter.java:215)
      	at com.sun.xml.ws.util.xml.XMLStreamReaderToXMLStreamWriter.bridge(XMLStreamReaderToXMLStreamWriter.java:124)
      	at com.sun.xml.ws.message.stream.StreamMessage.writePayloadTo(StreamMessage.java:381)
      	at com.sun.xml.ws.message.stream.StreamMessage.writeEnvelope(StreamMessage.java:417)
      	at com.sun.xml.ws.message.stream.StreamMessage.writeTo(StreamMessage.java:395)
      	at com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:230)
      	at com.sun.xml.ws.api.message.saaj.SAAJFactory.readAsSOAPMessage(SAAJFactory.java:279)
      	at com.sun.xml.ws.api.message.saaj.SAAJFactory.readAsSAAJ(SAAJFactory.java:206)
      	at com.sun.xml.ws.api.message.saaj.SAAJFactory.read(SAAJFactory.java:195)
      	at com.sun.xml.ws.message.AbstractMessageImpl.toSAAJ(AbstractMessageImpl.java:200)
      	at com.sun.xml.ws.api.message.MessageWrapper.readAsSOAPMessage(MessageWrapper.java:180)
      	at com.sun.xml.ws.handler.SOAPMessageContextImpl.getMessage(SOAPMessageContextImpl.java:86)
      

      The part of the message that causes this NPE looks as follows:

      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
          <soap:Body> 
              <sendMessage xmlns="http://www.foo.bar/schema/" xmlns:ns2="http://www.foo.bar/types/">;
                  <message xsi:type="ns2:someType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                      ...
                  </message> 
              </sendMessage> 
          </soap:Body> 
      </soap:Envelope>
      

      Here is used the default name space for the <sendMessage> and <message> tags.
      A similar message with the name space prefix (sch) explicitly specifies for these tags doesn't cause the NPE:

      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
          <soap:Body> 
              <sch:sendMessage xmlns:sch="http://www.foo.bar/schema/" xmlns:ns2="http://www.foo.bar/types/">;
                  <sch:message xsi:type="ns2:someType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
                      ...
                  </sch:message> 
              </sch:sendMessage> 
          </soap:Body> 
      </soap:Envelope>
      

      As work-around the following change in the code at com.sun.xml.ws.util.xml.XMLStreamReaderToXMLStreamWriter.handleStartElement(XMLStreamReaderToXMLStreamWriter.java:216) could be used:

              // start namespace bindings
              int nsCount = in.getNamespaceCount();
              for (int i = 0; i < nsCount; i++) {
                  out.writeNamespace(
                      fixNull(in.getNamespacePrefix(i)),
                      fixNull(in.getNamespaceURI(i)));    // zephyr doesn't like null, I don't know what is correct, so just fix null to "" for now
              }
      

      fixNull() for the first argument (nameSpacePrefix) of out.writeNamespace() has been added.

      This fixes the NPE-problem. However, I'm not sure, whether this is the best correction. By debugging the code I observed some strange behavior. I tried with breakpoints somewhere at the stack trace, e.g. at com.sun.xml.ws.api.message.saaj.SAAJFactory.read(SAAJFactory.java:195), and suddenly the problem disappeared by itself (without changing the code) - the call to in.getNamespacePrefix(i) at the code above returned an empty string instead of a null! This could suggest that this is a race-condition problem - a breakpoint suspends the current thread long enough to give another thread a chance to fix the name space prefix.

      Show
      kluch added a comment - Sorry, I've clicked something wrong. Here are the details: The following NPE is thrown by calling SOAPMessageContext.getMessage() by handling a message in an instance of SOAPHandler. java.lang.NullPointerException at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addNamespaceDeclaration(Unknown Source) at com.sun.xml.ws.api.message.saaj.SaajStaxWriter.writeNamespace(SaajStaxWriter.java:193) at com.sun.xml.ws.util.xml.XMLStreamReaderToXMLStreamWriter.handleStartElement(XMLStreamReaderToXMLStreamWriter.java:215) at com.sun.xml.ws.util.xml.XMLStreamReaderToXMLStreamWriter.bridge(XMLStreamReaderToXMLStreamWriter.java:124) at com.sun.xml.ws.message.stream.StreamMessage.writePayloadTo(StreamMessage.java:381) at com.sun.xml.ws.message.stream.StreamMessage.writeEnvelope(StreamMessage.java:417) at com.sun.xml.ws.message.stream.StreamMessage.writeTo(StreamMessage.java:395) at com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:230) at com.sun.xml.ws.api.message.saaj.SAAJFactory.readAsSOAPMessage(SAAJFactory.java:279) at com.sun.xml.ws.api.message.saaj.SAAJFactory.readAsSAAJ(SAAJFactory.java:206) at com.sun.xml.ws.api.message.saaj.SAAJFactory.read(SAAJFactory.java:195) at com.sun.xml.ws.message.AbstractMessageImpl.toSAAJ(AbstractMessageImpl.java:200) at com.sun.xml.ws.api.message.MessageWrapper.readAsSOAPMessage(MessageWrapper.java:180) at com.sun.xml.ws.handler.SOAPMessageContextImpl.getMessage(SOAPMessageContextImpl.java:86) The part of the message that causes this NPE looks as follows: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <sendMessage xmlns="http://www.foo.bar/schema/" xmlns:ns2="http://www.foo.bar/types/">; <message xsi:type="ns2:someType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... </message> </sendMessage> </soap:Body> </soap:Envelope> Here is used the default name space for the <sendMessage> and <message> tags. A similar message with the name space prefix (sch) explicitly specifies for these tags doesn't cause the NPE: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <sch:sendMessage xmlns:sch="http://www.foo.bar/schema/" xmlns:ns2="http://www.foo.bar/types/">; <sch:message xsi:type="ns2:someType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... </sch:message> </sch:sendMessage> </soap:Body> </soap:Envelope> As work-around the following change in the code at com.sun.xml.ws.util.xml.XMLStreamReaderToXMLStreamWriter.handleStartElement(XMLStreamReaderToXMLStreamWriter.java:216) could be used: // start namespace bindings int nsCount = in.getNamespaceCount(); for (int i = 0; i < nsCount; i++) { out.writeNamespace( fixNull(in.getNamespacePrefix(i)), fixNull(in.getNamespaceURI(i))); // zephyr doesn't like null, I don't know what is correct, so just fix null to "" for now } fixNull() for the first argument (nameSpacePrefix) of out.writeNamespace() has been added. This fixes the NPE-problem. However, I'm not sure, whether this is the best correction. By debugging the code I observed some strange behavior. I tried with breakpoints somewhere at the stack trace, e.g. at com.sun.xml.ws.api.message.saaj.SAAJFactory.read(SAAJFactory.java:195), and suddenly the problem disappeared by itself (without changing the code) - the call to in.getNamespacePrefix(i) at the code above returned an empty string instead of a null! This could suggest that this is a race-condition problem - a breakpoint suspends the current thread long enough to give another thread a chance to fix the name space prefix.
      Hide
      heikos added a comment -

      When will this bug be fixed?

      We have the same problem in combination with WebServices offered by Siebel Version 8.
      They respond a message with elements that have a default namespace defined like in kluch's example above.
      W3C states that this is ok - http://www.w3.org/TR/REC-xml-names/#scoping and the vendor of Siebel (Oracle) told us that they can't help us, because they are sending valid XML.

      The JVM built-in JAX-WS implementation does'nt have this problem.
      Tested with:

      • 1.6.0_27 (JAX-WS RI 2.1.6)
      • 1.7.0_51 (JAX-WS RI 2.2.4-b01)

      Best regards
      Heiko

      Show
      heikos added a comment - When will this bug be fixed? We have the same problem in combination with WebServices offered by Siebel Version 8. They respond a message with elements that have a default namespace defined like in kluch's example above. W3C states that this is ok - http://www.w3.org/TR/REC-xml-names/#scoping and the vendor of Siebel (Oracle) told us that they can't help us, because they are sending valid XML. The JVM built-in JAX-WS implementation does'nt have this problem. Tested with: 1.6.0_27 (JAX-WS RI 2.1.6) 1.7.0_51 (JAX-WS RI 2.2.4-b01) Best regards Heiko

        People

        • Assignee:
          Unassigned
          Reporter:
          kluch
        • Votes:
          2 Vote for this issue
          Watchers:
          2 Start watching this issue

          Dates

          • Created:
            Updated: