質問: インターネット接続がないときにspring schemalocationが失敗する 私はspringを使用しています。application-context.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:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:security="http://www.springframework.org/schema/security" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd" > .....インターネット接続が失われた場合、tomcatまたはjetty経由でアプリケーションを実行できません。それは与えます:[main] warn org.springframework.beans.factory.xml.xmlbeandefinitionreader - ignored xml validation warning org.xml.sax.saxparseexception: schema_reference.4: failed to read schema document '/spring-beans-2.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. at com.sun.org.apache.xerces.internal.util.errorhandlerwrapper.createsaxparseexception(errorhandlerwrapper.java:195) at com.sun.org.apache.xerces.internal.util.errorhandlerwrapper.warning(errorhandlerwrapper.java:96) at com.sun.org.apache.xerces.internal.impl.xmlerrorreporter.reporterror(xmlerrorreporter.java:380) at com.sun.org.apache.xerces.internal.impl.xmlerrorreporter.reporterror(xmlerrorreporter.java:318) at com.sun.org.apache.xerces.internal.impl.xs.traversers.xsdhandler.reportschemaerr(xsdhandler.java:2541) at com.sun.org.apache.xerces.internal.impl.xs.traversers.xsdhandler.reportschemawarning(xsdhandler.java:2532) at com.sun.org.apache.xerces.internal.impl.xs.traversers.xsdhandler.getschemadocument(xsdhandler.java:1836) at com.sun.org.apache.xerces.internal.impl.xs.traversers.xsdhandler.parseschema(xsdhandler.java:531) at com.sun.org.apache.xerces.internal.impl.xs.xmlschemaloader.loadschema(xmlschemaloader.java:552) at com.sun.org.apache.xerces.internal.impl.xs.xmlschemavalidator.findschemagrammar(xmlschemavalidator.java:2408) at com.sun.org.apache.xerces.internal.impl.xs.xmlschemavalidator.handlestartelement(xmlschemavalidator.java:1753) at com.sun.org.apache.xerces.internal.impl.xs.xmlschemavalidator.startelement(xmlschemavalidator.java:685) 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:3095) at com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$prologdriver.next(xmldocumentscannerimpl.java:921) 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:510) at com.sun.org.apache.xerces.internal.parsers.xml11configuration.parse(xml11configuration.java:807) 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:107) at com.sun.org.apache.xerces.internal.parsers.domparser.parse(domparser.java:225) at com.sun.org.apache.xerces.internal.jaxp.documentbuilderimpl.parse(documentbuilderimpl.java:283) at org.springframework.beans.factory.xml.defaultdocumentloader.loaddocument(defaultdocumentloader.java:75) at org.springframework.beans.factory.xml.xmlbeandefinitionreader.doloadbeandefinitions(xmlbeandefinitionreader.java:396) at org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:342) at org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:310) 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.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:124) at org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:92) at org.springframework.context.support.abstractrefreshableapplicationcontext.refreshbeanfactory(abstractrefreshableapplicationcontext.java:123) at org.springframework.context.support.abstractapplicationcontext.obtainfreshbeanfactory(abstractapplicationcontext.java:423) at org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:353) at org.springframework.web.context.contextloader.createwebapplicationcontext(contextloader.java:255) at org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:199) at org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:45) at org.mortbay.jetty.handler.contexthandler.startcontext(contexthandler.java:548) at org.mortbay.jetty.servlet.context.startcontext(context.java:136) at org.mortbay.jetty.webapp.webappcontext.startcontext(webappcontext.java:1250) at org.mortbay.jetty.handler.contexthandler.dostart(contexthandler.java:517) at org.mortbay.jetty.webapp.webappcontext.dostart(webappcontext.java:467) at org.mortbay.jetty.plugin.jetty6pluginwebappcontext.dostart(jetty6pluginwebappcontext.java:115) at org.mortbay.component.abstractlifecycle.start(abstractlifecycle.java:50) at org.mortbay.jetty.handler.handlercollection.dostart(handlercollection.java:152) at org.mortbay.jetty.handler.contexthandlercollection.dostart(contexthandlercollection.java:156) at org.mortbay.component.abstractlifecycle.start(abstractlifecycle.java:50) at org.mortbay.jetty.handler.handlercollection.dostart(handlercollection.java:152) at org.mortbay.component.abstractlifecycle.start(abstractlifecycle.java:50) at org.mortbay.jetty.handler.handlerwrapper.dostart(handlerwrapper.java:130) at org.mortbay.jetty.server.dostart(server.java:224) at org.mortbay.component.abstractlifecycle.start(abstractlifecycle.java:50) at org.mortbay.jetty.plugin.jetty6pluginserver.start(jetty6pluginserver.java:132) at org.mortbay.jetty.plugin.abstractjettymojo.startjetty(abstractjettymojo.java:441) at org.mortbay.jetty.plugin.abstractjettymojo.execute(abstractjettymojo.java:383) at org.mortbay.jetty.plugin.abstractjettyrunmojo.execute(abstractjettyrunmojo.java:210) at org.mortbay.jetty.plugin.jetty6runmojo.execute(jetty6runmojo.java:184) at org.apache.maven.plugin.defaultpluginmanager.executemojo(defaultpluginmanager.java:483) at org.apache.maven.lifecycle.defaultlifecycleexecutor.executegoals(defaultlifecycleexecutor.java:678) at org.apache.maven.lifecycle.defaultlifecycleexecutor.executestandalonegoal(defaultlifecycleexecutor.java:553) at org.apache.maven.lifecycle.defaultlifecycleexecutor.executegoal(defaultlifecycleexecutor.java:523) at org.apache.maven.lifecycle.defaultlifecycleexecutor.executegoalandhandlefailures(defaultlifecycleexecutor.java:371) at org.apache.maven.lifecycle.defaultlifecycleexecutor.executetasksegments(defaultlifecycleexecutor.java:332) at org.apache.maven.lifecycle.defaultlifecycleexecutor.execute(defaultlifecycleexecutor.java:181) at org.apache.maven.defaultmaven.doexecute(defaultmaven.java:356) at org.apache.maven.defaultmaven.execute(defaultmaven.java:137) at org.apache.maven.cli.mavencli.main(mavencli.java:356) at sun.reflect.nativemethodaccessorimpl.invoke0(native method) at sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) at sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) at java.lang.reflect.method.invoke(method.java:597) at org.codehaus.classworlds.launcher.launchenhanced(launcher.java:315) at org.codehaus.classworlds.launcher.launch(launcher.java:255) at org.codehaus.classworlds.launcher.mainwithexitcode(launcher.java:430) at org.codehaus.classworlds.launcher.main(launcher.java:375) 2009-11-13 15:31:25,675 [main] error org.springframework.web.context.contextloader - context initialization failed org.springframework.beans.factory.xml.xmlbeandefinitionstoreexception: line 23 in xml document from class path resource [application-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:404) at org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:342) at org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinit........ それを修正する方法はありますか?
回答: これを行うことで問題を解決しました。documentbuilderfactory factory = documentbuilderfactory.newinstance(); factory.setnamespaceaware(true); factory.setvalidating(false); // this avoid to search schema online factory.setattribute("http://java.sun.com/xml/jaxp/properties/schemalanguage", "http://www.w3.org/2001/xmlschema"); factory.setattribute("http://java.sun.com/xml/jaxp/properties/schemasource", "transactionmessage_v1.0.xsd"); このアプリケーションは、javaスタンドアロンオフラインアプリであることに注意してください。