JiBX
  1. JiBX
  2. JIBX-198

java.lang.IndexOutOfBoundsException: only START_TAG can have attributes TEXT seen

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JiBX 1.1.5
    • Fix Version/s: JiBX 1.1.6
    • Component/s: core
    • Labels:
      None
    • Environment:
      Windows XP SP 2, JDK 1.4.2
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      we found a problem with using nillable="true" and optional="true" on
      the very same value tag.

      think about the following example binding:
      <?xml version="1.0" encoding="ISO-8859-2"?>
      <binding>
      <mapping name="Data" class="usageoptreq.UsageOptReqData" ordered="false" flexible="true">
      <value name="optional1" field="optional1" nillable="true" usage="optional"/>
      <value name="optional2" field="optional2" nillable="true" usage="optional"/>
      <value name="optional3" field="optional3" nillable="true" usage="optional"/>
      <value name="optional4" field="optional4" nillable="true" usage="optional"/>
      </mapping>
      </binding>

      we get the following error during runtime (compilation works fine):

      java.lang.IndexOutOfBoundsException: only START_TAG can have attributes TEXT seen ...<optional1>OO Optional1<... @6:26
      at org.xmlpull.mxp1.MXParser.getAttributeValue(MXParser.java:927)
      at org.jibx.runtime.impl.XMLPullReaderFactory$XMLPullReader.getAttributeValue(XMLPullReaderFactory.java:395)
      at org.jibx.runtime.impl.UnmarshallingContext.getAttributeValue(UnmarshallingContext.java:356)
      at org.jibx.runtime.impl.UnmarshallingContext.attributeBoolean(UnmarshallingContext.java:1881)
      at usageoptreq.UsageOptReqData.JiBX_binding_unmarshal_1_2(UsageOptReqData.java)
      at usageoptreq.JiBX_bindingUsageOptReqData_access.unmarshal()
      at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2537)
      at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2680)
      at usageoptreq.UsageOptReqTest.testCompileAndTransform(UsageOptReqTest.java:34)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      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.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

      so far the only workaround we found is either not to use
      nillable="true" or not to use optional="true". you can guess that this
      is not what we wanted

      Explanantion for the attached zip archive:
      run the ant build file in srcipts/, then call the unit test. this produces the error.

        Issue Links

          Activity

          Hide
          Aaron Gaalswyk added a comment -

          Also seeing this with JIBX 1.1.5 using Axiom. If usage="optional" and nillable="true" are set on a value tag, and if the XML being unmarshalled has text in that value, then it the unmarshall will fail with:

          java.lang.IllegalStateException: Current state not START_ELEMENT
          at com.ctc.wstx.sr.BasicStreamReader.getAttributeValue(BasicStreamReader.java:636)
          at org.jibx.runtime.impl.StAXReaderWrapper.getAttributeValue(StAXReaderWrapper.java:378)
          at org.jibx.runtime.impl.UnmarshallingContext.getAttributeValue(UnmarshallingContext.java:356)
          at org.jibx.runtime.impl.UnmarshallingContext.attributeBoolean(UnmarshallingContext.java:1881)
          at com.uhg.ovations.portal.rxconnection.membersearch.service.endpoint.SearchMembersRequest.JiBX_jibx_binding_unmarshal_1_1(SearchMembersRequest.java)
          at com.uhg.ovations.portal.rxconnection.membersearch.service.endpoint.JiBX_jibx_bindingSearchMembersRequest_access.unmarshal()
          at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2537)
          at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2694)

          Show
          Aaron Gaalswyk added a comment - Also seeing this with JIBX 1.1.5 using Axiom. If usage="optional" and nillable="true" are set on a value tag, and if the XML being unmarshalled has text in that value, then it the unmarshall will fail with: java.lang.IllegalStateException: Current state not START_ELEMENT at com.ctc.wstx.sr.BasicStreamReader.getAttributeValue(BasicStreamReader.java:636) at org.jibx.runtime.impl.StAXReaderWrapper.getAttributeValue(StAXReaderWrapper.java:378) at org.jibx.runtime.impl.UnmarshallingContext.getAttributeValue(UnmarshallingContext.java:356) at org.jibx.runtime.impl.UnmarshallingContext.attributeBoolean(UnmarshallingContext.java:1881) at com.uhg.ovations.portal.rxconnection.membersearch.service.endpoint.SearchMembersRequest.JiBX_jibx_binding_unmarshal_1_1(SearchMembersRequest.java) at com.uhg.ovations.portal.rxconnection.membersearch.service.endpoint.JiBX_jibx_bindingSearchMembersRequest_access.unmarshal() at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2537) at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2694)
          Hide
          Dennis Sosnoski added a comment -

          Corrected the method used by the generated code in this case.

          Show
          Dennis Sosnoski added a comment - Corrected the method used by the generated code in this case.

            People

            • Assignee:
              Dennis Sosnoski
              Reporter:
              GŁnther Wieser
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: