【问题标题】:Ignite application is "Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/util]"Ignite 应用程序是“无法找到 XML 模式命名空间的 Spring NamespaceHandler [http://www.springframework.org/schema/util]”
【发布时间】:2023-04-03 08:56:01
【问题描述】:

我正在基于 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)无济于事。

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

非常感谢任何帮助!谢谢!

【问题讨论】:

  • 请分享您的 XML 配置。

标签: java xml spring maven ignite


【解决方案1】:

按照此处的指南进行操作: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>

不要显式添加 spring 依赖项。

运行:

mvn dependency:tree 

你应该得到类似的东西:

    [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

一种调试方法是基于现有示例启动一个新项目,然后添加您的 依赖项和代码。

可以在这里找到一个好的起点:https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java

【讨论】:

    【解决方案2】:

    我认为你错过了一个 util 命名空间声明:

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:util="http://www.springframework.org/schema/util"
        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
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util.xsd">
    

    这是根据https://ignite.apache.org/docs/latest/events/listening-to-events

    【讨论】:

      猜你喜欢
      • 2019-01-27
      • 2013-10-04
      • 2015-02-25
      • 2017-10-05
      • 1970-01-01
      • 2011-01-10
      相关资源
      最近更新 更多