Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3437

SAXParseException configuring event listeners in spring

    Details

      Description

      Part of my spring configuration:

      <drools:ksession id="statefulSession" type="stateful" kbase="kbase1">
      <drools:workingMemoryEventListener>
      <bean class="org.drools.event.DebugWorkingMemoryEventListener"/>
      </drools:workingMemoryEventListener>
      <drools:processEventListener>
      <bean class="org.drools.event.DebugProcessEventListener"/>
      </drools:processEventListener>
      </drools:ksession>

      throws :

      Caused by: org.xml.sax.SAXParseException; lineNumber: 15; columnNumber: 41;
      cvc-complex-type.2.4.a: Invalid content was found starting with element
      'drools:processEventListener'. One of
      '

      {"http://drools.org/schema/drools-spring":workingMemoryEventListener, "http://drools.org/schema/drools-spring":batch, "http://drools.org/schema/drools-spring":script, "http://drools.org/schema/drools-spring":configuration}

      ' is expected.
      at
      com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
      at
      com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
      at
      com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:387)
      at
      com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:321)
      at
      com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:421)
      at
      com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3186)
      at
      com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1810)
      at
      com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:709)
      at
      com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)
      at
      com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2732)
      at
      com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
      at
      com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
      at
      com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
      at
      com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:819)
      at
      com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:748)
      at
      com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
      at
      com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239)
      at
      com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:288)
      at
      org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
      at
      org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)

      But following configuration is OK:

      <drools:ksession id="statefulSession" type="stateful" kbase="kbase1">
      <drools:processEventListener>
      <bean class="org.drools.event.DebugProcessEventListener"/>
      </drools:processEventListener>
      </drools:ksession>

      Also this configuration is OK:

      <drools:ksession id="statefulSession" type="stateful" kbase="kbase1">
      <drools:workingMemoryEventListener>
      <bean class="org.drools.event.DebugWorkingMemoryEventListener"/>
      </drools:workingMemoryEventListener>
      </drools:ksession>

      Exception occurs only when both listeners are configured.

      probably because of bad position of elements; when listeners configured inside
      <drools:ksession> as shown above, current order required:
      agendaEventListener
      processEventListener
      workingMemoryEventListener

      but when configured through <drools:eventListeners> element and listeners
      attribute in <drools:ksession> element, order of event listeners does not
      matter. I think this is because of <xsd:all> resp. <xsd:sequence> inside
      drools-spring.xsd.

      It would by nice to unite both styles of configuration.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mfusco Mario Fusco
                Reporter:
                mfusco Mario Fusco
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: