Spring xmlns package schema error

We created a spring-batch application using eclipse. Whenever I run the program through eclipse, it works fine. But when I try to create and run the jar file created with ant, I get this ugly stack trace.

2012-Dec-27 11:10: 30,880 1141 [main] [] ERROR (CommandLineJobRunner.javahaps55): Operation Ends with an error: Line 12 to the XML document from the class path resource [launch-context.xml] is invalid; The nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Can not find the declaration of the 'beans' element. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in the XML document from the class path resource [launch-context.xml] is invalid; The nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of the 'beans' element. in org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions (XmlBeanDefinitionReader.javaictionary96) in org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinjfjefjfjordiem XefinitionfiRejfinjemforyfunction.js .xml.XmlBeanDefinitionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java:302) in org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions (AbstractBeanDefinitionReader.java:143) in org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions (AbstractBeanDefinitionReader .java: 178) in org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions (AbstractBeanDefinitionReader.java:149) in org.springframework.beans.factory.support.AbstractBeanDefinitionReader2eane AbstractBeanDefinitionReader2loadBeanBean abstractBeanDefinitionReader2loadBeanBeanBeanDefinitionReader2loadBeanBeanBeanDefinitionReader2load springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions (Abstra ctXmlApplicationContext.java:126) in org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions (AbstractXmlApplicationContext.java:92) in org.springframework.context.support.AbstractRefreshableApplicationFreworkFretextFreventFreventFreventFreventFreventFreventFreventFreventFreventFreventFrecha .support.AbstractApplicationContext.obtainFreshBeanFactory (AbstractApplicationContext.javarige67) in org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.javahaps97) in org.springframework.context.suppCml (ClassPas thanksmlApplicationContext.java: 139) in org.springframework.context.support.ClassPas thanksmlApplicationContext. ) : 574) on com.my.path.invoker.JobTest.main (JobTest.java:25) Called: org.xml.sax.SAXParseException: cvc-elt.1: cannot find declaration of element 'beans'. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException (ErrorHandlerWrapper.java:195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error (ErrorHandlerWrapper.java at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (XMLErrorReporter.javahaps84) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (XMLErrorReporter.javaictionary18) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement (XMLSchemaValidator.java:1916) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement (XMLSchemaValidator java: 705) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement (XMLNSDocumentScannerImpl.java-00-0000) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl $ NSContentRootHlesc.ook XMLNSDocumentScannerImpl.java:626) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl $ FragmentConten tDriver.next (XMLDocumentFragmentScannerImpl.javahaps103) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl $ PrologDriver.next (XMLDocumentScannerImpl.java:922) at com.sun.org.apache.xerces.internal. impl.XMLDocumentScannerImpl.next (XMLDocumentScannerImpl.java:648) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next (XMLNSDocumentScannerImpl.java:140) at com.sun.org.apache.xerces.internal. impl.XMLDocumentFragmentScannerImpl.scanDocument (XMLDocumentFragmentScannerImpl.javaโˆ—11) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (XML11Configuration.Java: 808) at com.sun.org.apache.xerces.ternal. parsers.XML11Configuration.parse (XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse (XMLParser.java:119) at com.sun.org.apache.xerces.internal. parsers.DOMParser.parse (DOMParser.java:235) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse (DocumentBuilderImpl.java:284) in org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument (DefaultDocumentLoader.java:75) in org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions (XmlBeanDefinitionReader.j ...

Basically saying that on line 11 he cannot find the declaration for the beans element. Here is my launch context.

<?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> 

and my build.xml that generated the jar.

 <?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> 

I spent more than 3 days on this to no avail. I made sure that the xsd links that I create are compatible with the version of spring jar that I use.

Any help would be greatly appreciated.

Edit:

The same run-context.xml runs in eclipse; when building through this ant build.xml, it throws this error.

Edit 2:

I try to pack all the jars that are in one fat jar. I came across several posts saying that I cannot do this. To reference a packaged jar, I need either one-jar or eclipse jarinjarloader . Otherwise, I will have to keep the hanging banks outside my main bank. I will try these options and come back if this is a real problem. Meanwhile, if any of you have any materials for this editing, please update your answers, I will mark them as correct.

+4
source share
3 answers

Is the XML editor / validator of your choice to successfully validate the context of your application (the one you invoke the launch context)? It is invalid because http://www.springframework.org/schema/batch/spring-batch-2.1.xsd invalid.

However, what you posted (is this just an excerpt?) Does not even need a batch namespace. Therefore, you can remove it by turning it into valid XML.

0
source

In the ant script, you have a dependency for spring 3.0.3, and in the application context, you include spring 3.0, maybe the problem?

0
source

If your runtime server firewall is blocking access to the external Internet (which is usually good), you will need to use spring.handlers and spring.schemas to help the application analyze your context files.

This will refer to the schemas present in your framework libraries, rather than trying to get them out of the Internet.

/META-INF/spring.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 
0
source

All Articles