java - Ignite 应用程序是“无法找到 XML 模式命名空间的 Spring NamespaceHandler [http://www.springframework.org/schema/util]”
问题描述
我正在基于 Ignite 2.9.1 Github 项目中的一个示例开发 Apache Ignite 服务。该应用程序构建良好,使用与 Ignite 2.9.1 示例项目完全相同的依赖项集。
我现在花了很多时间尝试诊断和修复此错误:
Exception in thread "main" class org.apache.ignite.IgniteException: Failed to instantiate Spring XML application context [springUr\
l=jar:file:/home/ignitedev/dev/esi/ignite-writebehind/target/ignite-writebehind-1.0-SNAPSHOT-shaded.jar!/apache-example-ignite.xml\
, err=Configuration problem: Unexpected failure during bean definition parsing
Offending resource: URL [jar:file:/home/ignitedev/dev/esi/ignite-writebehind/target/ignite-writebehind-1.0-SNAPSHOT-shaded.jar!/ap\
ache-example-ignite.xml]
Bean 'ignite.cfg'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration pro\
blem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/util]
Offending resource: URL [jar:file:/home/ignitedev/dev/esi/ignite-writebehind/target/ignite-writebehind-1.0-SNAPSHOT-shaded.jar!/ap\
ache-example-ignite.xml]
Property 'includeEventTypes'
-> Bean 'ignite.cfg']
at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1089)
at org.apache.ignite.Ignition.start(Ignition.java:356)
at com.tapestrysoutions.esi.ignitebase.client.IgniteWriteBehindJavaConfig.main(IgniteWriteBehindJavaConfig.java:42)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context [springUrl=jar:fil\
e:/home/ignitedev/dev/esi/ignite-writebehind/target/ignite-writebehind-1.0-SNAPSHOT-shaded.jar!/apache-example-ignite.xml, err=Con\
figuration problem: Unexpected failure during bean definition parsing
Offending resource: URL [jar:file:/home/ignitedev/dev/esi/ignite-writebehind/target/ignite-writebehind-1.0-SNAPSHOT-shaded.jar!/ap\
ache-example-ignite.xml]
Bean 'ignite.cfg'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration pro\
blem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/util]
Offending resource: URL [jar:file:/home/ignitedev/dev/esi/ignite-writebehind/target/ignite-writebehind-1.0-SNAPSHOT-shaded.jar!/ap\
ache-example-ignite.xml]
从我发现的各种搜索结果来看,这通常是由于缺少依赖项造成的。我尝试添加建议的依赖项(spring-beans,spring-security-config)无济于事。
如果可以提供更好的错误消息来指示可能的解决方案,那就太好了,但我知道这可能很困难。
任何帮助是极大的赞赏!谢谢!
解决方案
Follow the guide here: https://ignite.apache.org/docs/latest/understanding-configuration#spring-xml-configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
...
</bean>
</beans>
don't explicitly add spring dependencies.
run:
mvn dependency:tree
you should get something similar to:
[INFO] +- org.apache.ignite:ignite-spring:jar:2.9.1:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.26.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.26.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.26.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.3.26.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.3.26.RELEASE:compile
[INFO] | +- org.springframework:spring-tx:jar:4.3.26.RELEASE:compile
[INFO] | +- org.springframework:spring-jdbc:jar:4.3.26.RELEASE:compile
One way to debug is to start a new project based on an existing example then add your dependencies and code to it.
A good starting point could be found here: https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java
推荐阅读
- object - MPI_Gather 对象向量
- facebook-graph-api - Facebook SDK edge.create 已弃用。有什么选择吗?
- python - 如何显示 0-N 范围内的所有“超级数字”数字
- mongodb - 类型错误:无法在 result.toArray 处读取 undefined\n 的属性“n”
- java - Intellij - 无法在外部驱动器中启动项目:java.nio.file.AccessDeniedException
- python - 更改不同树视图的行高 tkitner
- git - 一个空的合并提交可以让我重新合并
- java - RxJava ConcurrentModificationException
- react-native - 用字符串和动态索引反应原生动态 setstate
- php - 根据使用会话选择的行获取数据