Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-78

NPE when processing XMLStreamReader Midstream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • Version 2
    • Version 2
    • None
    • None
    • Latest CVS, Windows XP, Java 1.5

    Description

      I am attempting to read in a SOAP response into XmlBeans with an XMLStreamReader. I've skipped to body in the XMLStreamReader. When doing a XmlObject.Factory.parse( streamReader ) it throws this:

      java.lang.IllegalArgumentException: prefix cannot be "null" when creating a QName
      at javax.xml.namespace.QName.<init>(Unknown Source)
      at com.bea.xml.stream.MXParser.getName(MXParser.java:1432)
      at org.apache.xmlbeans.impl.newstore2.Locale.loadXMLStreamReader(Locale.java:979)
      at org.apache.xmlbeans.impl.newstore2.Locale.parseToXmlObject(Locale.java:703)
      at org.apache.xmlbeans.impl.newstore2.Locale.parseToXmlObject(Locale.java:693)
      at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:217)
      at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:645)
      at XMLStreamReaderBug.testBug(XMLStreamReaderBug.java:25)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

      This is fixed easily enough, by checking if the prefix is null in the Locale class and acting accordingly. Once this is done though, I get:

      java.lang.NullPointerException
      at org.apache.xmlbeans.impl.newstore2.Cur$CurLoadContext.finish(Cur.java:3032)
      at org.apache.xmlbeans.impl.newstore2.Locale.loadXMLStreamReader(Locale.java:1069)
      at org.apache.xmlbeans.impl.newstore2.Locale.parseToXmlObject(Locale.java:703)
      at org.apache.xmlbeans.impl.newstore2.Locale.parseToXmlObject(Locale.java:693)
      at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:217)
      at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:645)
      at XMLStreamReaderBug.testBug(XMLStreamReaderBug.java:25)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

      I'll attach a testcase showing this bug and my patch for Locale which checks for a null prefix. The null prefix bug could also be problem with the StAX RI - however I'ved tried it with both the RI and Woodstox. Both give me the same issue with the prefix being null.

      Attachments

        1. amazon2.xml
          2 kB
          Daniel Diephouse
        2. depth.patch
          1 kB
          Daniel Diephouse
        3. prefix.patch
          0.9 kB
          Daniel Diephouse
        4. prefixanddepth.patch
          2 kB
          Daniel Diephouse
        5. XMLStreamReaderBug.java
          1 kB
          Daniel Diephouse

        Activity

          People

            ljones Lawrence Aston Jones
            dandiep Daniel Diephouse
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: