首页 > 解决方案 > 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)无济于事。

如果可以提供更好的错误消息来指示可能的解决方案,那就太好了,但我知道这可能很困难。

任何帮助是极大的赞赏!谢谢!

标签: javaxmlspringmavenignite

解决方案


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


推荐阅读