6 Replies Latest reply on Feb 1, 2007 5:34 PM by alesj

    Mixing schemas WildcardBinding exception

    alesj

      I'm using this xml:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <beans xmlns="urn:jboss:spring-beans:2.0">
      
       <bean id="testBean" class="org.jboss.test.spring.support.SimpleBean">
       <property name="refBean"><ref bean="oldBean"/></property>
       </bean>
      
       <bean xmlns="urn:jboss:bean-deployer:2.0" name="oldBean" class="org.jboss.test.spring.support.OldBean">
       <property name="javaBeanString"><value>JavaBean</value></property>
       </bean>
      
      </beans>


      and I get the following exception:
      org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/projects/microcontainer/classes/test/spring-int/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml@13,9
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:173)
       at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:133)
       at org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer.deploy(BasicXMLDeployer.java:135)
       at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.deploy(MicrocontainerTestDelegate.java:212)
       at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.deploy(MicrocontainerTestDelegate.java:283)
       at org.jboss.test.kernel.junit.MicrocontainerTestDelegate.setUp(MicrocontainerTestDelegate.java:78)
       at org.jboss.test.spring.test.TempSpringMicrocontainerTestDelegate.setUp(TempSpringMicrocontainerTestDelegate.java:48)
       at org.jboss.test.AbstractTestSetup.setUp(AbstractTestSetup.java:63)
       at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
       at junit.extensions.TestSetup.run(TestSetup.java:23)
       at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
       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.application.AppMain.main(AppMain.java:90)
      Caused by: java.lang.ClassCastException: org.jboss.xb.binding.sunday.unmarshalling.WildcardBinding
       at org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler.setParent(DefaultElementHandler.java:109)
       at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.endRepeatableParticle(SundayContentHandler.java:730)
       at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.endElement(SundayContentHandler.java:138)
       at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.endElement(SaxJBossXBParser.java:353)
       at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
       at org.apache.xerces.xinclude.XIncludeHandler.endElement(Unknown Source)
       at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(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:169)
       ... 23 more


      When I do it the other way around - defining root element deployment as MC schema, and using Spring bean inside deployment - it works.

        • 1. Re: Mixing schemas WildcardBinding exception
          aloubyansky

          For some reason an extension of the DefaultElementHandler is used for a wildcard.
          I haven't looked at the schema and initialization yet. But this happens for a repeated wildcard. Have a look at org.jboss.test.xml.AnyComplexTypeUnitTestCase. Maybe it'll give you an idea.

          • 2. Re: Mixing schemas WildcardBinding exception
            alesj

             

            "alex.loubyansky@jboss.com" wrote:
            But this happens for a repeated wildcard. Have a look at org.jboss.test.xml.AnyComplexTypeUnitTestCase. Maybe it'll give you an idea.


            What is a repeated wildcard?

            I did look at the test, but I don't see how it helps with my mixin' xml.

            • 3. Re: Mixing schemas WildcardBinding exception

              Have a look at how
              org.jboss.kernel.plugins.deployment.xml.DeploymentWildcardHandler
              is used in the MC xml.

              • 4. Re: Mixing schemas WildcardBinding exception
                alesj

                I've added missing DeploymentWildcardHandler to Spring beans element handler, but w/o success, I still get the same exception.

                 public static void initBeansHandler(TypeBinding typeBinding)
                 {
                 typeBinding.setHandler(SpringBeansHandler.HANDLER);
                 // handle beans
                 typeBinding.pushInterceptor(SpringSchemaBinding.beanQName, SpringBeansInterceptor.INTERCEPTOR);
                 // todo alias
                 // todo import
                 // Deployment can take wildcards
                 typeBinding.getWildcard().setWildcardHandler(DeploymentWildcardHandler.HANDLER);
                 }
                




                • 5. Re: Mixing schemas WildcardBinding exception

                  Your Schema was wrong.

                  You had an infinite number of wildcards in an infinite number of choices.

                  This is a bug in JBossXB since this should create a list of wildcards
                  instead it tries to set the second wildcard in the first wildcard.
                  There is an open bug report/test case about this.

                  I removed the unbounded from the xsd:any and now it works properly.

                  • 6. Re: Mixing schemas WildcardBinding exception
                    alesj

                     

                    "adrian@jboss.org" wrote:
                    Your Schema was wrong.

                    This is schema copied from Spring dist - with slight changes, but nothing with beans in beans element.

                    "adrian@jboss.org" wrote:

                    I removed the unbounded from the xsd:any and now it works properly.

                    Thanks.
                    I think it would've taken me ages to figure this one out. :-)