java Weblogic 10.3.1.0 正在使用 com.bea.core.apache.commons.net_1.0.0.0_1-4-1.jar ... 我想从我的代码中使用 commons-net-2.0.jar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3376046/
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
Weblogic 10.3.1.0 is using com.bea.core.apache.commons.net_1.0.0.0_1-4-1.jar... I want to use commons-net-2.0.jar from my code
提问by Cal
Weblogic 10.3.1.0 is using com.bea.core.apache.commons.net_1.0.0.0_1-4-1.jar... I want to use commons-net-2.0.jar from my code.
Weblogic 10.3.1.0 正在使用 com.bea.core.apache.commons.net_1.0.0.0_1-4-1.jar ... 我想从我的代码中使用 commons-net-2.0.jar。
How can I force it to use the newer JAR in my code only?
如何强制它仅在我的代码中使用较新的 JAR?
回答by Pascal Thivent
I want to use commons-net-2.0.jar from my code.
我想从我的代码中使用 commons-net-2.0.jar。
WebLogic uses a parent class loader first strategyand you basically have two options to tweak this behavior:
WebLogic 使用父类加载器优先策略,您基本上有两个选项可以调整此行为:
- Use the prefer-web-inf-classeselement in a
weblogic.xmlWeb application deployment descriptor (that goes in WEB-INF next to theweb.xml) ~or~ - Package your war insider an EAR and use WebLogic Filtering classloaderthat you configure in a
weblogic-application.xmldescriptor (that goes in META-INF next to theapplication.xml)
- 在Web 应用程序部署描述符中使用prefer-web-inf-classes元素
weblogic.xml(位于 旁边的 WEB-INF 中web.xml)~或~ - 将您的War内部人员打包为 EAR 并使用您在描述符中配置的WebLogic过滤类加载器
weblogic-application.xml(位于 旁边的 META-INF 中application.xml)
Here is an example weblogic.xml:
这是一个示例 weblogic.xml:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic- web-app.xsd">
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
Here is an example weblogic-application.xml:
这是一个示例 weblogic-application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
<prefer-application-packages>
<package-name>javax.jws.*</package-name>
</prefer-application-packages>
</weblogic-application>
The former option is simpler but is global to the webapp. The later introduces more complexity if you're not currently using an EAR packaging but gives finer control.
前一个选项更简单,但对 web 应用程序是全局的。如果您当前没有使用 EAR 包装但提供更好的控制,后者会引入更多的复杂性。
See also
也可以看看
回答by Vineet Reynolds
Have you tried putting the required JAR in \WEB-INF\lib of the WAR, \APP-INF\lib of the EAR or the \lib directory of the EAR file?
您是否尝试将所需的 JAR 放在 WAR 的 \WEB-INF\lib、EAR 的 \APP-INF\lib 或 EAR 文件的 \lib 目录中?
If your project is a standalone web project (with no EJBs), placing the JAR in WEB-INF\lib should be sufficient. For enterprise applications that possibly have EJB modules and Web modules bundled in a EAR file, APP-INF\lib should work, although I'm not so sure about WebLogic Server's support for the library directory (usually a \lib directory in the EAR file, but sometimes configurable via application.xml) concept brought out in Java EE 5.
如果您的项目是一个独立的 Web 项目(没有 EJB),将 JAR 放在 WEB-INF\lib 中就足够了。对于可能将 EJB 模块和 Web 模块捆绑在 EAR 文件中的企业应用程序,APP-INF\lib 应该可以工作,尽管我不太确定 WebLogic Server 对库目录(通常是 EAR 文件中的 \lib 目录)的支持,但有时可通过 application.xml 进行配置)概念在 Java EE 5 中提出。
EDIT: In the scenario where the application server's library is loaded ahead of the one present in the application, WebLogic Server's feature of filtered classloaderswill aid in ensuring that the application always has the right classes loaded from its classpath, instead of the server's classpath.
编辑:在应用程序服务器的库在应用程序中的库之前加载的情况下,WebLogic Server 的过滤类加载器功能将有助于确保应用程序始终从其类路径加载正确的类,而不是服务器的类路径。

