我正在从java类调用spring bean,并从scala程序调用该java类。我已经使用maven将我的程序打包在一个jar中,并且正在爆炸其中的spring依赖项。但是当调用bean时,它会抛出下降的异常 -
> User class threw exception: Job aborted due to stage failure: Task 0
> in stage 5.0 failed 4 times, most recent failure: Lost task 0.3 in
> stage 5.0 (TID 6, hostname03):
> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
> Line 6 in XML document from URL
> [jar:file:/hadoop/yarn/local/usercache/root/filecache/101/SomeJar-1.0-SNAPSHOT-job.jar!/SpringContext.xml]
> is invalid; nested exception is org.xml.sax.SAXParseException;
> lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the
> declaration of element 'beans'. at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
我的SpringContext.xml看起来像 -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<import resource="classpath:RuleSpringContext.xml" />
<bean id="serviceImpl" class="com.org.name.services.dao.ServiceImpl" />
<bean id="contextInitializer" class="com.org.name.services.config.AppContextInitializer" />
</beans>
任何帮助将不胜感激。此外,当我从eclipse bean运行程序时,调用它只是当我运行我的jar时问题即将到来。我正在使用spark-submit运行jar。
答案 0 :(得分:0)
似乎xml xsi:schemaLocation声明错误。
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-[version].xsd
将[版本]替换为您正在使用的适当弹簧版本。