【发布时间】:2015-07-05 13:58:18
【问题描述】:
我正在从一个 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。
【问题讨论】:
标签: java spring scala maven spring-mvc