Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

java - Ignite application is "Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/util]"

I'm working on an Apache Ignite service based on one of the examples from the Ignite 2.9.1 Github project. The application builds fine, using the exact same set of dependencies as the Ignite 2.9.1 example project.

I've now spent quite a bit of time trying to diagnose and fix this error:

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]                                                                                                           
                                                                                                                               

From the various things I've found searching, this is typically caused by a missing dependency. I've tried adding the suggested dependencies (spring-beans, spring-security-config) to no avail.

It'd be great if a better error message were possible indicating possible solutions, but I understand that may be difficult.

Any help is greatly appreciated! Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...