1 Reply Latest reply on Jul 1, 2010 12:46 PM by rainer knupfer

    Problem SchemaValidation with schema importing other schema

    rainer knupfer Newbie


      I had to change the validation against a schema. The new schema imports a new schema:




      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema targetNamespace="http://bom.swissgrid.ch/schedule/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:schedule="http://bom.swissgrid.ch/schedule/" xmlns:datatypes="http://bom.swissgrid.ch/datatypes/" elementFormDefault="qualified">
          <xs:import namespace="http://bom.swissgrid.ch/datatypes/" schemaLocation="datatypes.xsd"/>


      --> datatypes.xsd


      While deploying my esb i get following error:


        Deployment "jboss.esb.vfszip:/C:/Java-Packages/JBoss/JBossAS/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ftp_t
      o_ws_service.esb/" is in error due to the following reason(s): org.xml.sax.SAXParseException: src-resolve: Cannot resolv
      e the name 'datatypes:AcknowledgementDocumentStatus' to a(n) 'type definition' component.


              at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:993)
              at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:939)
              at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:873)



      my jboss.esb.xml configuration:

      <!-- perform a schema validation -->
                      <action name="validation">
                          <property name="schema" value="/validation/schedule.xsd"/>



      any idea?


        • 1. Re: Problem SchemaValidation with schema importing other schema
          rainer knupfer Newbie

          In my opinion this is a bug. The class org.jboss.soa.esb.actions.validation.SchemaValidationAction loads or resolve only the first schema and not the related one.


          See code:


               * Creates a Validator instance which will be used for schema validation.
               * @param xsd           The schema to validate against.
               * @return Validator    The Validator instance.
               * @throws ConfigurationException Is an exception is thrown while trying to create the schema.
              private Schema createSchema(final String xsd) throws ConfigurationException
                  final SchemaFactory schemafactory = SchemaFactory.newInstance(schemaLanguage);
                      return schemafactory.newSchema(new StreamSource(ClassUtil.getResourceAsStream(xsd, getClass())));
                  catch (final SAXException e)
                      throw new ConfigurationException("Could not create a validator for schema '" + xsd + "'", e);


          If I load manually all the schemas, the problem is not there anymore


          StreamSource streamSource=new StreamSource(ClassUtil.getResourceAsStream(xsd, getClass()));
          StreamSource streamSource1=new StreamSource(ClassUtil.getResourceAsStream("/datatypes.xsd", getClass()));
          StreamSource[] arrStreamSources={streamSource1,streamSource};

          return schemafactory.newSchema(arrStreamSources);




          So, I would suggest JBossEsb team to have a look on this issue. In the meantime I'll try to implement my own createSchema class