java 如何让 Weblogic 10 更喜欢 myApp.war:/WEB-INF/lib/ 中的 jars 而不抛出 VerifyErrors?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6278517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 15:10:32  来源:igfitidea点击:

How do I make Weblogic 10 prefer the jars in myApp.war:/WEB-INF/lib/ without throwing VerifyErrors?

javaweblogicclassloaderweb-inf

提问by neu242

The Weblogic classloader seems to prefer system libraries over the libraries in my war's WEB-INF/lib/.

Weblogic 类加载器似乎更喜欢系统库而不是我的WEB-INF/lib/.

I've tried setting the following in WEB-INF/weblogic.xml, without success:

我试过在 中设置以下内容WEB-INF/weblogic.xml,但没有成功:

<weblogic-web-app>
    <container-descriptor>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>
</weblogic-web-app>

This just gives me a lot of VerifyErrors:

这只是给了我很多验证错误:

exception is java.lang.VerifyError: (class: org/apache/xerces/parsers/AbstractSAXParser, method: parse signature: (Lorg/xml/sax/InputSource;)V) Incompatible object argument for function call
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:730)
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        Truncated. see log file for complete stacktrace

(I'm trying to avoid packaging the WAR into an EAR.)

(我试图避免将 WAR 打包到 EAR 中。)

回答by artbristol

I was never able to fix this satisfactorily, other than by specifying -Djavax.xml.parsers.SAXParserFactory=[xerces sax parser factory class name](and so on for the other JAXP factories like validation SchemaFactory) when starting Weblogic.

除了-Djavax.xml.parsers.SAXParserFactory=[xerces sax parser factory class name]在启动 Weblogic 时指定(以及其他 JAXP 工厂,如验证 SchemaFactory等)之外,我一直无法令人满意地解决这个问题。

None of the filtering / prefer-web-infstuff worked, possibly due to Weblogic requiring JAXP libraries on startup before it even reads any of the WAR / EAR config files.

过滤/prefer-web-inf东西都不起作用,可能是因为 Weblogic 在启动时需要 JAXP 库,甚至在它读取任何 WAR/EAR 配置文件之前。

回答by Jeff West

This video gives a good overview of the options you have for configuring the WebLogic FilteringClassLoaders:

该视频很好地概述了用于配置 WebLogic FilteringClassLoaders 的选项:

http://www.youtube.com/watch?v=ArLTKapjV_8

http://www.youtube.com/watch?v=ArLTKapjV_8

回答by Geoffrey De Smet

I had this problem too with tomcat-arquillian. Turns out "xml-apis 2.0.2" was in my classpath, which is actually xml-apis 1.0.b2 and which is too old to be compatible with xercesImpl 2.9.1 which requires xml-apis 1.3.04.

我在使用 tomcat-arquillian 时也遇到了这个问题。原来“xml-apis 2.0.2”在我的类路径中,它实际上是 xml-apis 1.0.b2,它太旧了,无法与需要 xml-apis 1.3.04 的 xercesImpl 2.9.1 兼容。