Spring批处理xmlns架构错误



我们已经使用eclipse构建了一个spring批处理应用程序。每当我通过eclipse执行程序时,它运行得很好。但是,当我尝试生成并运行使用ant创建的jar文件时,我会得到这个丑陋的堆栈跟踪。

2012-Dec-27 11:10:30880 1141〔main〕〔〕错误(CommandLineJobRunner.java:355):作业因错误而终止:中的第12行类路径资源[launch context.XML]中的XML文档无效;嵌套异常为org.xml。ax.SAXParseException:cvc elt.1:无法查找元素"beans"的声明。org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:类路径资源[launch context.XML]中XML文档的第12行无效;嵌套异常为org.xml。ax.SAXParseException:cvc elt.1:找不到元素"beans"的声明。在org.springframework.beans.factory.xmlXmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)在org.springframework.beans.factory.xmlXmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)在org.springframework.beans.factory.xmlXmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReporter.java:143)在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReporter.java:178)在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReporter.java:149)在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReporter.java:212)在org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)在org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)在org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshtableApplicationContext.java:130)在org.springframework.context.support.AbstractApplicationContext.georgenFreshBeanFactory(AbstractApplicationContext.java:467)在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)在org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:139)在org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:83)在org.springframework.batch.core.slaunch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:282)在org.springframework.batch.core.slaunch.support.CommandLineJobRunner.main(CommandLineJobRunner:574)在com.my.path.invoker.JobTest.main(JobTest.java:25)引起:org.xml.ax.SAXParseException:cvc elt.1:找不到声明元素"beans"的。在com.sun.org/apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWraper.java:195)在com.sun.org/apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWraper.java:131)在com.sun.org/apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReportr.java:384)在com.sun.org/apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReportr.java:318)在com.sun.org/apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:11916)在com.sun.org/apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)在com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)在com.sun.org/apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)在com.sun.org/apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFractionScannerImpl.java:3103)在com.sun.org/apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScanner impl.java:922)在com.sun.org/apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScanner impl.java:648)在com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)在com.sun.org/apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFractionScannerImpl.java:511)在com.sun.org/apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)在com.sun.org/apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)在com.sun.org/apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)在com.sun.org/apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)在com.sun.org/apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)在org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)…还有16个

它的基本意思是在第11行找不到元素bean的声明。这是我的发布上下文。

<?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:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>file:batch.properties</value>
<value>file:application.properties</value>
</list>
</property>
</bean>

<context:component-scan base-package="com.my.path" />
<import resource="classpath:/META-INF/spring/batch-context.xml" />
<import resource="classpath:/META-INF/spring/module-context.xml" />

</beans>

以及生成jar的build.xml。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project basedir="." default="jar" name="ERS2Utilities">
<property environment="env"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<path id="CLASSPATH">
<pathelement location="target/classes"/>
<pathelement location="target/test-classes"/>
<!-- 
<pathelement location="src/main/resources/lib/antlr-2.7.7.jar"/>
<pathelement location="src/main/resources/lib/antlr-runtime-3.2.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.instrument.tomcat-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.jms-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.js-2.1.1.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.web-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.web.portlet-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.web.servlet-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.web.struts-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.webflow-2.1.1.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/slf4j-api-1.6.1.jar"/>
<pathelement location="src/main/resources/lib/slf4j-api.jar"/>
<pathelement location="src/main/resources/lib/slf4j-log4j12-1.6.1.jar"/>
<pathelement location="src/main/resources/lib/commons-digester.jar"/>
-->
<pathelement location="src/main/resources/lib/com.springsource.org.aopalliance-1.0.0.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.aop-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.asm-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.aspects-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.beans-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.binding-2.1.1.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.context-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.context.support-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.core-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.expression-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.instrument-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.jdbc-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.orm-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.oxm-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.test-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/org.springframework.transaction-3.0.3.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/spring-batch-infrastructure-2.1.9.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/spring-batch-core-2.1.9.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/spring-batch-test-2.1.9.RELEASE.jar"/>
<pathelement location="src/main/resources/lib/commons-beanutils.jar"/>
<pathelement location="src/main/resources/lib/commons-collections-3.1.jar"/>
<pathelement location="src/main/resources/lib/commons-dbcp-1.4.jar"/>
<pathelement location="src/main/resources/lib/commons-lang-2.6.jar"/>
<pathelement location="src/main/resources/lib/commons-logging-1.1.1.jar"/>
<pathelement location="src/main/resources/lib/commons-pool-1.5.4.jar"/>
<pathelement location="src/main/resources/lib/junit-4.7.jar"/>
<pathelement location="src/main/resources/lib/ojdbc14.jar"/>
<pathelement location="src/main/resources/lib/log4j-1.2.16.jar"/>
<pathelement location="src/main/resources/lib/HashUtility.jar"/>
<pathelement location="src/main/resources/lib/commons-io-2.4.jar"/>
<pathelement location="src/main/resources/lib/mockito-all-1.9.5.jar"/>
</path>
<target name="init">
<mkdir dir="target/classes"/>
<mkdir dir="target/test-classes"/>
<copy includeemptydirs="false" todir="target/classes">
<fileset dir="src/main/resources">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="target/classes">
<fileset dir="src/main/java">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="target/test-classes">
<fileset dir="src/test/java">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="target/classes">
<fileset dir="src/test/resources">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="target/classes"/>
<delete dir="target/test-classes"/>
</target>

<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="target/classes" source="${source}" target="${target}">
<src path="src/main/resources"/>
<classpath refid="CLASSPATH"/>
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="target/classes" source="${source}" target="${target}">
<src path="src/main/java"/>
<classpath refid="CLASSPATH"/>
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="target/test-classes" source="${source}" target="${target}">
<src path="src/test/java"/>
<classpath refid="CLASSPATH"/>
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="target/classes" source="${source}" target="${target}">
<src path="src/test/resources"/>
<classpath refid="CLASSPATH"/>
</javac>
</target>
<!-- <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target> -->
<target name="JobTest">
<java classname="com.my.path.invoker.JobTest" failonerror="true" fork="yes">
<arg line="launch-context.xml oiaExtractorJob"/>
<classpath refid="CLASSPATH"/>
</java>
</target>
<target name="jar" depends="build-project">
<copy todir="build/main" file="src/main/resources/log4j.xml"/>
<copy todir="build/main" file="application.properties"/>
<copy todir="build/main" file="batch.properties"/>
<copy todir="build/main" file="src/main/resources/ERSUtilities.sh"/>
<copy todir="build/main" file="src/main/resources/ERSUtilities.bat"/>
<jar destfile="build/main/ERS2SupportingUtilities.jar">
<fileset dir="target/classes"/>
<restrict>
<name name="**/*.class"/>
<archives>
<zips>
<fileset dir="./src/main/resources/lib" includes="**/*.jar"/>
</zips>
</archives>
</restrict>
<manifest>
<attribute name="Main-Class" value="com.my.path.invoker.JobTest"/>
<attribute name="Class-Path" value="./lib/log4j-1.2.16.jar
./lib/org.springframework.context-3.0.3RELEASE.jar
./lib/org.springframework.asm-3.0.3.RELEASE.jar
./lib/junit-4.7.jar
./lib/org.springframework.orm-3.0.3.RELEASE.jar
./lib/org.springframework.transaction-3.0.3.RELEASE.jar
./lib/org.springframework.aspects-3.0.3.RELEASE.jar
./lib/commons-pool-1.5.4.jar
./lib/org.springframework.core-3.0.3.RELEASE.jar
./lib/commons-logging-1.1.1.jar
./lib/HashUtility.jar
./lib/org.springframework.expression-3.0.3.RELEASE.jar
./lib/commons-lang-2.6.jar
./lib/org.springframework.instrument-3.0.3.RELEASE.jar
./lib/mockito-all-1.9.5.jar
./lib/com.springsource.org.aopalliance-1.0.0.jar
./lib/ojdbc14.jar
./lib/commons-io-2.4.jar
./lib/commons-collections-3.1.jar
./lib/org.springframework.jdbc-3.0.3.RELEASE.jar
./lib/spring-batch-infrastructure-2.1.9.RELEASE.jar
./lib/org.springframework.context.support-3.0.3.RELEASE.jar
./lib/commons-dbcp-1.4.jar
./lib/spring-batch-test-2.1.9.RELEASE.jar
./lib/org.springframework.beans-3.0.3.RELEASE.jar
./lib/org.springframework.oxm-3.0.3.RELEASE.jar
./lib/org.springframework.aop-3.0.3.RELEASE.jar
./lib/commons-beanutils.jar
./lib/org.springframework.binding-2.1.1.RELEASE.jar
./lib/spring-batch-core-2.1.9.RELEASE.jar
./lib/org.springframework.test-3.0.3.RELEASE.jar
./launch-context.xml
./log4j.xml"
/>
</manifest>
</jar>
</target>
</project>

我已经花了三天多的时间在这上面,但没有任何效果。我已经确保我正在制作的xsd引用与我正在使用的springjar版本兼容。

如有任何帮助,我们将不胜感激。

编辑:

相同的launch-context.xml在eclipse中工作,当通过给定的ant build.xml构建时,它会抛出此错误。

编辑2:

我正试图把所有依赖的罐子装进一个肥罐子里。我遇到过一些帖子表明我不能那样做。要引用打包的jar,我需要one-jar或eclipse的jarinjarloader。否则,我将不得不把从属罐子放在我的主罐子外面。如果这是真正的问题,我会尝试这些选择并回来。同时,如果你们中的任何人对此编辑有任何意见,请更新你们的答案,我会将其标记为正确的。

您选择的XML编辑器/验证器是否成功验证了您的应用程序上下文(您称之为启动上下文)?它无效,因为http://www.springframework.org/schema/batch/spring-batch-2.1.xsd无效。

然而,您发布的内容(只是摘录吗?)甚至不需要batch命名空间。因此,您可以删除它,从而将其转换为有效的XML。

在ant脚本中,您对spring 3.0.3有依赖关系,而在应用程序上下文中,您包含了spring 3.0,这可能是问题所在吗?

如果执行服务器的防火墙阻止了对外部互联网的访问(这通常是一件好事),那么您需要使用spring.handlers和spring.schemas来帮助应用程序解析上下文文件。

这将引用框架库中的模式,而不是试图从互联网上提取它们。

/META-INFspring.handlers

http://www.springframework.org/schema/batch=org.springframework.batch.core.configuration.xml.CoreNamespaceHandler
http://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler
http://www.springframework.org/schema/jdbc=org.springframework.jdbc.config.JdbcNamespaceHandler

/META-INF/spring.schemas

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd=org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd

相关内容

  • 没有找到相关文章

最新更新