org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'drools:grid-node'.
I’m getting this error when I add a grid-node and ksession to my spring xml. I did some searching and looks like it a classpath issue. What dependency am I missing here ?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://drools.org/schema/drools-spring org/drools/container/spring
http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd">
<drools:grid-node id="node1"/>
<drools:ksession id="ksession1" type="stateful" kbase="kbase1" node="node1" />
My pom.xml has the following for Drools.
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-camel</artifactId>
<version>${drools.version}</version>
<exclusions>
<!-- This ensures that we use the latest version of Spring jars and not
the one that comes with drools.version. -->
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</exclusion>
<exclusion>
<artifactId>camel-xstream</artifactId>
<groupId>org.apache.camel</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-spring</artifactId>
<version>${drools.version}</version>
</dependency>
This error is being issued because the Drools XSD can’t be located. In this comment in the Drools user list, it is stated that the XSD’s aren’t publicly available, and the
xsi:schemaLocationattribute in the XML is mapping that XSD tohttp://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd, which doesn’t resolve to the proper XSD.Spring should be automatically handling the XSD resolution given the
xmlns:drools="http://drools.org/schema/drools-spring"attribute. One of the Drools JARs should be including aMETA-INF/spring.handlersfile defining the XSD mapping for thedroolsnamespace. Something along the lines of :Which should be automatically handling the XSD file included in the Drools JARs.
Try removing the last two lines of your
xsi:schemaLocationattribute in order to let Spring automatically resolve the XSD.Some related links:
Of course, you could also extract that XSD from the JAR file, place it in an accessible directory from your classpath and use a classpath relative URL in
xsi:schemaLocation.By the way, it’s probably a copy&paste error, but your
<beans>element is missing its closing tag.EDIT : It seems that Drools wasn’t providing the
spring.handlersproperly (at least as of December 2010, see Drools + Spring without internet ). You might need to dig through the JARs to get the XSD and reference it directly inxsi:schemaLocation.