org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:匹配的通配符是strict [英] org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict
问题描述
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'.
当我向spring xml添加网格节点和ksession时,我收到此错误。我做了一些搜索,看起来像是一个类路径问题。我在这里缺少什么依赖?
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" />
我的pom.xml对于Drools有以下内容。
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>
推荐答案
此错误正在发布,因为Drools XSD可以'找到位置。在此评论中在Drools用户列表中,声明XSD不公开,XML中的 xsi:schemaLocation
属性将XSD映射到 http://drools.org/schema/drools-spring org / drools / container / spring / drools-spring-1.2.0.xsd
,它无法解析为正确的XSD。
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:schemaLocation
attribute in the XML is mapping that XSD to http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd
, which doesn't resolve to the proper XSD.
Spring应该自动处理XSD分辨率给定 xmlns:drools =http://drools.org/schema/drools-spring
属性。其中一个Drools JAR应该包含一个 META-INF / spring.handlers
文件,用于定义 drools
的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 a META-INF/spring.handlers
file defining the XSD mapping for the drools
namespace. Something along the lines of :
http://drools.org/schema/drools-spring=some.classpath.visible.package.xsdfile.xsd
哪个应自动处理Drools JAR中包含的XSD文件。
Which should be automatically handling the XSD file included in the Drools JARs.
尝试删除 xsi:schemaLocation
属性的最后两行,以便让Spring自动解析XSD。
Try removing the last two lines of your xsi:schemaLocation
attribute in order to let Spring automatically resolve the XSD.
一些相关链接:
- 没有互联网连接时,Spring schemaLocation失败。特别是David Resnick的回答。
- Spring reference的附录D.5注册处理程序和架构。
- Spring schemaLocation fails when there is no internet connection. Specially David Resnick's answer.
- Spring reference's Appendix D.5 Registering the handler and the schema.
当然,您也可以从JAR文件中提取该XSD,将其放在类路径的可访问目录中并使用类路径 xsi:schemaLocation
中的相对URL。
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
.
顺便说一下,它可能是一个复制和粘贴错误,但你的< beans>
元素缺少它结束标记。
By the way, it's probably a copy&paste error, but your <beans>
element is missing its closing tag.
编辑:似乎Drools没有提供 spring.handlers
正确(至少截至2010年12月,请参阅 Drools + Spring没有互联网)。您可能需要深入了解JAR以获取XSD并直接在 xsi:schemaLocation
中引用它。
EDIT : It seems that Drools wasn't providing the spring.handlers
properly (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 in xsi:schemaLocation
.
这篇关于org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:匹配的通配符是strict的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!