我们已经使用 eclipse 构建了一个 spring-batch 应用程序。每当我通过 eclipse 执行程序时,它都运行良好。但是当我尝试生成并运行使用 ant 创建的 jar 文件时,我得到了这个难看的堆栈跟踪。
2012-Dec-27 11:10:30,880 1141 [main][] ERROR (CommandLineJobRunner.java:355): Job Terminated in error: Line 12 in XML document from class path resource [launch-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document from class path resource [launch-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: 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) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83) at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:282) at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574) at com.my.path.invoker.JobTest.main(JobTest.java:25) Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the 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:131) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) 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:400) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3103) 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:511) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) at com.sun.org.apache.xerces.internal.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) at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388) ... 16 more
它基本上是说在第 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>
我已经在这上面花了超过 3 天的时间,但无济于事。我已确保我制作的 xsd 引用与我使用的 spring jar 版本兼容。
如有任何帮助,我们将不胜感激。
相同的 launch-context.xml 在 eclipse 中工作,它在通过给定的 ant build.xml 构建时抛出此错误。
我正在尝试将所有相关的 jar 打包到一个 fat jar 中。我遇到过一些暗示我不能那样做的帖子。要引用打包的 jar,我需要 one-jar 或 eclipse 的 jarinjarloader。否则我将不得不将依赖 jar 放在我的主 jar 之外。如果这是真正的问题,我会尝试这些选项并返回。同时,如果您对此编辑有任何意见,请更新您的答案,我会将其标记为正确。
最佳答案
您选择的 XML 编辑器/验证器是否成功验证了您的应用程序上下文(您称为启动上下文的那个)?它无效,因为 http://www.springframework.org/schema/batch/spring-batch-2.1.xsd 无效。
但是,您发布的内容(只是摘录吗?)甚至不需要 batch 命名空间。因此,您可以删除它,从而将它变成有效的 XML。
关于xml - Spring批处理xmlns模式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14067314/
我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
我正在使用Ruby2.1.1和Rails4.1.0.rc1。当执行railsc时,它被锁定了。使用Ctrl-C停止,我得到以下错误日志:~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.2/lib/spring/client/run.rb:47:in`gets':Interruptfrom~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.2/lib/spring/client/run.rb:47:in`verify_server_version'from~/.rvm/gems/ruby-2.1.1/gems/spring-1.1.
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file