http://jira.jboss.com/jira/browse/JBXB-56 is an issue that describes a simple testcase in head that shows this behavior.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Scott M Stark
Sent: Saturday, March 04, 2006 11:08 AM
To: jboss-development@lists.sourceforge.net
Subject: [JBoss-dev] minOccurs=0 not being used

In working on setting up a testcase for a custom JavaBeanSchemaInitializer, I'm seeing an incorrect validation exception:
 
[code]
org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/cvs/JBossHead/jboss-head/testsuite/output/resources/xml/mbeanserver/testXMBean2.xml
 at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:125)
 at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:128)
 at org.jboss.test.xml.XMBean2UnitTestCase.testMbeanService(XMBean2UnitTestCase.java:54)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Requested element {urn:jboss-test:xmbean:2.0}descriptors is not allowed in this position in the sequence. The next element should be {urn:jboss-test:xmbean:2.0}description
 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:151)
 at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:189)
 at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:269)
 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:121)
 ... 20 more
[/code]
 
The relevant schema is:
 
[code]
<?xml version="1.0" encoding="UTF-8"?>
<!--
   The JBossXMBeanXB schema.
   @version $Id: jboss_xmbean_1_2.dtd,v 1.3 2006/01/03 17:45:30 dimitris Exp $
   @author [EMAIL PROTECTED]
   @author Dimitris Andreadis
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   elementFormDefault="qualified"
   attributeFormDefault="unqualified"
   targetNamespace="urn:jboss-test:xmbean:2.0"
   xmlns:xmbean="urn:jboss-test:xmbean:2.0"
   xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
   >
   <xs:annotation>
      <xs:documentation>The global jbossxb binding information</xs:documentation>
      <xs:appinfo>
      <jbxb:schemaBindings>
         <jbxb:ignoreUnresolvedFieldOrClass>false</jbxb:ignoreUnresolvedFieldOrClass>
         <jbxb:replacePropertyRefs>true</jbxb:replacePropertyRefs>
      </jbxb:schemaBindings>
   </xs:appinfo>
   </xs:annotation>
 
   <xs:element name="mbean">
       <xs:annotation>
          <xs:documentation>
             <![CDATA[
             The mbean element is the root element of the XMBean container descriptor.
     <xmbean:mbean xmlns:xmbean="urn:jboss-test:xmbean:2.0">
       ...
     </xmbean:mbean>
         ]]>
          </xs:documentation>
          <xs:appinfo>
             <jbxb:class impl="org.jboss.mx.metadata.xb.ModelMBeanInfoSupportWrapper"/>
          </xs:appinfo>
       </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" ref="xmbean:description"/>
                <xs:element minOccurs="0" ref="xmbean:descriptors"/>
                <xs:element minOccurs="0" ref="xmbean:class"/>
                <xs:element minOccurs="0" maxOccurs="unbounded" ref="xmbean:constructor"/>
                <xs:element minOccurs="0" maxOccurs="unbounded" ref="xmbean:attribute"/>
                <xs:element minOccurs="0" maxOccurs="unbounded" ref="xmbean:operation"/>
                <xs:element minOccurs="0" maxOccurs="unbounded" ref="xmbean:notification"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
 
...
 
   <xs:element name="description" type="xs:string">
       <xs:annotation>
          <xs:documentation>The description element provides human readable descriptive text for constructors,
             attributes, operations, paramters, notifications, etc.</xs:documentation>
       </xs:annotation>
   </xs:element>
[/code]
 
The document I'm testing with:
[code]
<?xml version="1.0" encoding="UTF-8"?>
 
<mbean xmlns="urn:jboss-test:xmbean:2.0"
   code="org.jboss.naming.JNDIBindingService"
   name="jboss.tests:service=JNDIBindingService">
 
   <descriptors>
      <interceptors>
         <custom1:javabean xlmns:custom1="urn:jboss:simplejavabean:1.0"
            code="org.jboss.test.jmx.interceptors.JNDISecurity"
            attr1="some-text1" attr2="some-text2" />
         <custom1:interceptor xlmns:custom1="urn:jboss:simplejavabean:1.0"
            code="org.jboss.naming.interceptors.ProxyFactoryInterceptor"
            proxyName="some-name" />
 
         <interceptor
code="org.jboss.mx.interceptor.PersistenceInterceptor2" />
         <interceptor code="org.jboss.mx.interceptor.ModelMBeanInterceptor" />
         <interceptor code="org.jboss.mx.interceptor.ObjectReferenceInterceptor" />
      </interceptors>
   </descriptors>
</mbean>
[/code]
 
I don't see an existing jira issue for something like this. Is this a known issue?
 

Reply via email to