您的位置:首页 > 编程语言 > Java开发

weblogic中使用commons-lang包报java.lang.NoSuchMethodError解决办法

2013-12-27 19:52 417 查看
        在weblogic中发布的应用使用了commons-lang-2.4.jar,但在调用。StringUtils.startsWith方法时,报异常

java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.startsWith(Ljava/lang/String;Ljava/lang/String;)Z。

        其实这个问题原因就是weblogic启动时预先加载了一个commons-lang的包(bea11g\modules\com.bea.core.apache.commons.lang_2.1.0.jar)。导致应用下面的2.4的包未加载。

        解决办法:

在WEB-INF下面添加weblogic.xml文件,其中添加以下内容:

 

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

     可以使weblogic优先加载应用WEB-INF/lib下面的jar包。

 

    最终我的weblogic.xml为:

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
<container-descriptor> <prefer-web-inf-classes>true</prefer-web-inf-classes> </container-descriptor>
<charset-params>
<input-charset>
<resource-path>/*</resource-path>
<java-charset-name>GBK</java-charset-name>
</input-charset>
</charset-params>
<context-root>/reins</context-root>
</weblogic-web-app>

 

 

     weblogic11g 中预先加载的包中apache的包如下:

bea11g\modules\com.bea.core.apache.commons.collections_3.2.0.jar
bea11g\modules\com.bea.core.apache.commons.lang_2.1.0.jar
bea11g\modules\com.bea.core.apache.commons.logging.api_1.1.0.jar
bea11g\modules\com.bea.core.apache.commons.logging_1.1.0.jar
bea11g\modules\com.bea.core.apache.commons.net_1.0.0.0_1-4-1.jar
bea11g\modules\com.bea.core.apache.commons.pool_1.3.0.jar
bea11g\modules\com.bea.core.apache.dom_1.0.0.0.jar
bea11g\modules\com.bea.core.apache.log4j_1.1.0.0_1-2-15.jar
bea11g\modules\com.bea.core.apache.log4j_1.2.13.jar
bea11g\modules\com.bea.core.apache.logging_1.0.0.0.jar
bea11g\modules\com.bea.core.apache.oro_1.0.0.0_2-0-8.jar
bea11g\modules\com.bea.core.apache.regexp_1.0.0.0_1-4.jar
bea11g\modules\com.bea.core.apache.velocity.dep_1.4.jar
bea11g\modules\com.bea.core.apache.velocity_1.4.jar
bea11g\modules\com.bea.core.apache.xalan_2.7.0.jar
bea11g\modules\com.bea.core.apache.xerces.resolver_2.8.1.jar
bea11g\modules\com.bea.core.apache.xerces.xml-apis_2.8.1.jar
bea11g\modules\com.bea.core.apache.xercesImpl_2.8.1.jar
bea11g\modules\com.bea.core.apache.xml.security_1.3.0.jar
bea11g\modules\com.bea.core.apache.xml.serializer_2.7.0.jar

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐