2 Replies Latest reply on Jul 28, 2006 12:42 AM by Juergen Zimmermann

    1.0.2: Exception when client receives a JavaBean

    Juergen Zimmermann Master

      Using the new version 1.0.2 on the client side I get the following exception when the JBoss server transmits a JavaBean. Any hint is appreciated!

      2006-07-27 15:21:09,668 DEBUG org.jboss.ws.soap.SOAPContentElement - setXMLFragment: <result xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><ns_art:art xmlns:ns_art='http://de.hska.ws/jaws'>privat</ns_art:art><ns_id:id xmlns:ns_id='http://de.hska.ws/jaws'>1</ns_id:id><ns_nachname:nachname xmlns:ns_nachname='http://de.hska.ws/jaws'>Alpha</ns_nachname:nachname><ns_rabatt:rabatt xmlns:ns_rabatt='http://de.hska.ws/jaws'>0</ns_rabatt:rabatt><ns_vorname:vorname xmlns:ns_vorname='http://de.hska.ws/jaws'>Adrian</ns_vorname:vorname></result>
      2006-07-27 15:21:09,668 DEBUG org.jboss.ws.soap.SOAPContentElement - getObjectValue [xmlType={http://de.hska.ws/jaws}KundeData,javaType=class de.hska.ws.KundeData]
      2006-07-27 15:21:09,678 ERROR org.jboss.ws.jaxrpc.CallImpl - Call invocation failed with unkown Exception
      javax.xml.rpc.JAXRPCException: org.jboss.ws.binding.BindingException: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Requested element {http://de.hska.ws/jaws}art is not allowed in this position in the sequence. The next element should be art
       at org.jboss.ws.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:292)
       at org.jboss.ws.binding.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:233)
       at org.jboss.ws.binding.EndpointInvocation.getReturnValue(EndpointInvocation.java:182)
       at org.jboss.ws.jaxrpc.CallImpl.syncOutputParams(CallImpl.java:873)
       at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:704)
       at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:404)
       at org.jboss.ws.jaxrpc.CallProxy.invoke(CallProxy.java:148)
       at $Proxy2.findKunde(Unknown Source)
       at de.hska.test.WebServicesTest.testFindKunde(Unknown Source)
       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:585)
       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.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
       at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
       at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
      Caused by: org.jboss.ws.binding.BindingException: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Requested element {http://de.hska.ws/jaws}art is not allowed in this position in the sequence. The next element should be art
       at org.jboss.ws.jaxrpc.encoding.JAXBDeserializer.deserialize(JAXBDeserializer.java:100)
       at org.jboss.ws.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:229)
       ... 23 more
      Caused by: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Requested element {http://de.hska.ws/jaws}art is not allowed in this position in the sequence. The next element should be art
       at org.jboss.ws.jaxb.JBossXBUnmarshallerImpl.unmarshal(JBossXBUnmarshallerImpl.java:67)
       at org.jboss.ws.jaxrpc.encoding.JAXBDeserializer.deserialize(JAXBDeserializer.java:92)
       ... 24 more
      Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: Requested element {http://de.hska.ws/jaws}art is not allowed in this position in the sequence. The next element should be art
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:156)
       at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:126)
       at org.jboss.ws.jaxb.JBossXBUnmarshallerImpl.unmarshal(JBossXBUnmarshallerImpl.java:63)
       ... 25 more
      Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Requested element {http://de.hska.ws/jaws}art is not allowed in this position in the sequence. The next element should be art
       at org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding$1.startElement(SequenceBinding.java:214)
       at org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding$Cursor.startElement(ModelGroupBinding.java:152)
       at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:195)
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:301)
       at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
       at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
       at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:152)
       ... 27 more


        • 1. Re: 1.0.2: Exception when client receives a JavaBean
          Anatoly Osiko Newbie

          I have found this feature of JBossWS empirically as well, whatever worked with the Axis based ws4jee stopped working .... JBossWS appears to be strictly adheres to XML Schema definitions. Which is good. The by definition defines not only the elements it contains, but also their order (compare with ). Therefore the missing element in the message raises the error (on schema validation I guess), unless it explicitly defined with nillable="yes" attribute.
          In the latter case, the element would be inserted in the message as 'nil' element, of course.

          So the above is the solution. But not exactly.
          There is a subtle case with the primitive types. If you expect the JavaBean to contain a primitive type, e.g. int, then - don't, if it's declared as nillable. The primitive type element declared in the schema as nillable, will be generated as a Java object wrapper, e.g. Integer. As it should be. If your insist that property in JavaBean still be an int, then don't declare it nillable, but make sure it is always included in the resulting message.
          Of course, the above doesn't effect xsd:string.

          PS I wonder if there is a way to switch the schema validation off? May that will also increase the speed of JAXB processing.

          • 2. Re: 1.0.2: Exception when client receives a JavaBean
            Juergen Zimmermann Master

            My WSDL is generated by the ANT task provided by JBossWS. The schema definition looks as follows:

            <?xml version="1.0" encoding="UTF-8"?>
            <definitions name='KundenverwaltungService' targetNamespace='http://de.hska.ws/jaws' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://de.hska.ws/jaws' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
             <types>
             <schema targetNamespace='http://de.hska.ws/jaws' xmlns='http://www.w3.org/2001/XMLSchema' xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://de.hska.ws/jaws' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
             <complexType name='KundeData'>
             <sequence>
             <element name='art' nillable='true' type='string'/>
             <element name='id' type='long'/>
             <element name='nachname' nillable='true' type='string'/>
             <element name='rabatt' type='int'/>
             <element name='vorname' nillable='true' type='string'/>
             </sequence>
             </complexType>
            ...


            The server doesn't throw any exception, and log shows these entries:
            2006-07-28 06:34:05,116 DEBUG org.jboss.ws.soap.SOAPContentElement - setObjectValue: {id=1, nachname=Alpha, vorname=Adrian, art=privat, rabatt=0}
            2006-07-28 06:34:05,116 DEBUG org.jboss.ws.soap.SOAPContentElement - getXMLFragment from Object [xmlType={http://de.hska.ws/jaws}KundeData,javaType=class de.hska.ws.KundeData]
            2006-07-28 06:34:05,116 DEBUG org.jboss.ws.soap.SOAPContentElement - xmlFragment: <result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ns_art:art xmlns:ns_art="http://de.hska.ws/jaws">privat</ns_art:art><ns_id:id xmlns:ns_id="http://de.hska.ws/jaws">1</ns_id:id><ns_nachname:nachname xmlns:ns_nachname="http://de.hska.ws/jaws">Alpha</ns_nachname:nachname><ns_rabatt:rabatt xmlns:ns_rabatt="http://de.hska.ws/jaws">0</ns_rabatt:rabatt><ns_vorname:vorname xmlns:ns_vorname="http://de.hska.ws/jaws">Adrian</ns_vorname:vorname></result>