Jar未启动:无法找到XML架构命名空间的Spring NamespaceHandler攻击资源:类路径资源[root-servlet.xml]

时间:2018-05-17 04:12:52

标签: java spring spring-mvc ant spring-rest

尝试使用java -jar erp.jar从命令提示符运行我的jar文件时出现异常

例外是:

F:\PROJECT\JarFile>java -jar erpcore.jar
2018-05-17 08:23:38.669:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
2018-05-17 08:23:38.721:INFO:oejs.AbstractConnector:Started SocketConnector@0.0.
0.0:3001
2018-05-17 08:23:38.820:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
2018-05-17 08:23:38.821:INFO:/:Initializing Spring root WebApplicationContext
2018-05-17 08:23:41.104:WARN:oejuc.AbstractLifeCycle:FAILED o.e.j.s.ServletConte
xtHandler{/,null}: org.springframework.beans.factory.parsing.BeanDefinitionParsi
ngException: Configuration problem: Unable to locate Spring NamespaceHandler for
 XML schema namespace [http://www.springframework.org/schema/context]|Offending
resource: class path resource [root-servlet.xml]|
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Config
uration problem: Unable to locate Spring NamespaceHandler for XML schema namespa
ce [http://www.springframework.org/schema/context]|Offending resource: class pat
h resource [root-servlet.xml]|
        at org.springframework.beans.factory.parsing.FailFastProblemReporter.err
or(FailFastProblemReporter.java:70)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderC
ontext.java:85)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderC
ontext.java:80)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.er
ror(BeanDefinitionParserDelegate.java:287)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.pa
rseCustomElement(BeanDefinitionParserDelegate.java:1359)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.pa
rseCustomElement(BeanDefinitionParserDelegate.java:1352)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentRe
ader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:172)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentRe
ader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:142)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentRe
ader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registe
rBeanDefinitions(XmlBeanDefinitionReader.java:508)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB
eanDefinitions(XmlBeanDefinitionReader.java:392)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea



This is a rest api project written in Spring which run on a jetty server. Workspace is running perfectly but when I created a jar using ant script, its broken.

---- src文件夹包含所有java类。 ---- src / recources文件夹包含所有必需的文件,例如root-servlet.xml,dispatcher-servlet.xl,log.properties。 ---- lib包含所有jar

我的蚂蚁脚本就像..

                                                                                                                                                                                       

    <target name="create_run_jar" depends="copyResourse">
        <jar destfile="${dir.jarfile}/erpcore.jar" filesetmanifest="mergewithoutmain">
            <manifest>
                <attribute name="Main-Class" value="com.erp.main.ErpMain"/>
                <attribute name="Class-Path" value="."/>
            </manifest>
            <fileset dir="${dir.workspace}/erpcore/bin"/>
            <fileset dir="${dir.workspace}/erpcore/bin/resources/"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-webmvc-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-web-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-client-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-http-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-io-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-security-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-server-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-servlet-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-servlets-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-util-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-webapp-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/servlet-api-3.0.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-context-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/commons-io-2.5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-core-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-beans-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jetty-continuation-8.1.21.v20160908.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/commons-logging-1.2.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-aop-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-expression-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/guava-21.0.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-jdbc-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/spring-tx-5.0.0.M5.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/sqljdbc4-4.0.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/commons-codec-1.10.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jackson-databind-2.6.3.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jackson-core-2.6.3.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/jackson-annotations-2.6.3.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="${dir.workspace}/erpcore/lib/log4j-1.2.17.jar"/>
        </jar>
    </target>   
</project>

任何人都可以帮我找到根本问题。

0 个答案:

没有答案