1. JiBX
  2. JIBX-218

nillable="true" results in IllegalStateException: Current state not START_ELEMENT


    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: JiBX 1.1.5
    • Fix Version/s: JiBX 1.2
    • Component/s: None
    • Labels:
    • Number of attachments :


      I have a problem with jibx databinding in webservises built with Axis2.

      My part built with the mentioned frameworks is contacting remote implementation of webservices. Remote webservises are built with very different frameworks and are working without any problems. They responce on my webservice request with XML like shown below (i've renamed namespaces and stripped lots of unimportant fields):

      <StrErrorCode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
      <NativeError xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
      <LogSequence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>

      The appropirate part of XSD from appropriate webservice definition should look like:

      <?xml version="1.0" encoding="UTF-8"?>
      <xsd:complexType name="ResponseStateType">
      <xsd:element name="ErrorCode" type="xsd:int" minOccurs="1" nillable="false" />
      <xsd:element name="StrErrorCode" type="xsd:string" minOccurs="0" nillable="true" />
      <xsd:element name="Message" type="xsd:string" minOccurs="1" nillable="false" />
      <xsd:element name="NativeError" type="xsd:string" minOccurs="0" nillable="true" />
      <xsd:element name="LogSequence" type="xsd:long" minOccurs="0" nillable="true" />

      And my binding.xml then looks like (a bit complicated due to original namespaces hierarhy):

      <namespace uri="http://www.my.com/request" default="elements" />
      <structure map-as="com.my.PageableSearchResult" />

      <mapping abstract="true" class="com.my.PageableSearchResult">
      <namespace prefix="lr" uri="http://www.my.com/response" default="elements"/>
      <structure name="ResponseState" field="responseState" usage="required" type="com.my.ResponseStateType"/>

      <mapping abstract="true" class="com.my.ResponseStateType">
      <namespace prefix="respst" uri="http://www.my.com/common" default="elements"/>
      <value name="ErrorCode" field="errorCode" usage="required"/>
      <value name="StrErrorCode" field="strErrorCode" nillable="true" usage="optional"/>
      <value name="Message" field="message" usage="required"/>
      <value name="NativeError" field="nativeError" nillable="true" usage="optional"/>
      <value name="LogSequence" field="logSequence" nillable="true" usage="optional"/>

      The problem is in the fact that unmarshaling of the webservces response on my side fails. The original exception is:

      "IllegalStateException: Current state not START_ELEMENT"

      Then the exception is wrapped into AxisFault when being thown out.

      The IllegalStateException is thrown from the place shown in this stacktrace (stopped on "IllegalStateException trow" breakpoint):

      Thread [btpool0-6] (Suspended (exception IllegalStateException))
      ValidatingStreamReader(BasicStreamReader).getAttributeValue(String, String) line: 641
      OMStAXWrapper.getAttributeValue(String, String) line: 656
      StAXReaderWrapper.getAttributeValue(String, String) line: 378
      UnmarshallingContext.getAttributeValue(String, String) line: 356
      UnmarshallingContext.attributeBoolean(String, String, boolean) line: 1881
      ResponseStateType.JiBX_binding_unmarshal_1_0(UnmarshallingContext) line: not available
      ResponseStateType.JiBX_binding_unmarshal_1_1(UnmarshallingContext) line: not available
      FileInfoSearchResult(PageableSearchResult).JiBX_binding_unmarshal_1_1(UnmarshallingContext) line: not available
      FileInfoSearchResult.JiBX_binding_unmarshal_2_0(UnmarshallingContext) line: not available
      JiBX_bindingFileInfoSearchResult_access2.unmarshal(Object, IUnmarshallingContext) line: not available
      UnmarshallingContext.unmarshalElement(Class) line: 2512
      FileInfoWServiceStub.fromOM(OMElement, Class, Map) line: 370
      FileInfoWServiceStub.getFileInfo(FindFileInfo, HeaderType) line: 221
      TransactionsWsClient.getFileInfoList(FindFileInfo) line: 278
      FileinfoMBean.doSearch() line: 31
      FileinfoMBean.initListener(ActionEvent) line: 35
      NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
      NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
      Method.invoke(Object, Object...) line: 585
      AstValue.invoke(EvaluationContext, Class[], Object[]) line: 187
      MethodExpressionImpl.invoke(ELContext, Object[]) line: 297
      TagMethodExpression.invoke(ELContext, Object[]) line: 68
      LegacyMethodBinding.invoke(FacesContext, Object[]) line: 69
      HtmlCommandLink(UICommand).broadcast(FacesEvent) line: 89
      UIViewRoot._broadcastForPhase(PhaseId) line: 97
      UIViewRoot.processApplication(FacesContext) line: 171
      InvokeApplicationExecutor.execute(FacesContext) line: 32
      LifecycleImpl.executePhase(FacesContext, PhaseExecutor, PhaseListenerManager) line: 95
      LifecycleImpl.execute(FacesContext) line: 70
      FacesServlet.service(ServletRequest, ServletResponse) line: 139

      According to stack variables (reader buffer and pointer) the element being processed (and that is causing this error) is:

      <StrErrorCode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>

      Must note that the bug looks like JIBX-198, but is being trown in some other place.

      The exception it thrown from BasicStreamReader.getAttributeValue():

      public String getAttributeValue(String nsURI, String localName) {
      if (mCurrToken != START_ELEMENT)

      { throw new IllegalStateException(ErrorConsts.ERR_STATE_NOT_STELEM); // THROWNHERE }

      return mAttrCollector.getValue(nsURI, localName);

      An must note that value of mCurrToken is END_ELEMENT. I think that the code looking for value of "nil" is confused by the fact that the element being processed (and containing nil="true") is at the same time both START_ELEMENT and END_ELEMENT).


        Dennis Sosnoski added a comment -

        Please try this using 1.1.6.

        Dennis Sosnoski added a comment - Please try this using 1.1.6.
        Dennis Sosnoski made changes -
        Field Original Value New Value
        Assignee Dennis Sosnoski [ dsosnoski ]
        Dennis Sosnoski made changes -
        Fix Version/s JiBX 1.1.6 [ 14068 ]
        Fix Version/s JiBX 1.2 [ 14415 ]
        Dennis Sosnoski added a comment -

        Without a test case or further feedback I'll assume it's been fixed in the 1.2.x series of releases.

        Dennis Sosnoski added a comment - Without a test case or further feedback I'll assume it's been fixed in the 1.2.x series of releases.
        Dennis Sosnoski made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Cannot Reproduce [ 5 ]
        Dennis Sosnoski made changes -
        Status Resolved [ 5 ] Closed [ 6 ]


          • Assignee:
            Dennis Sosnoski
            Michael Bannij


            • Created: