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

来源:互联网 发布:app看漫画软件 编辑:程序博客网 时间:2024/06/05 14:55

        在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

 

0 0
原创粉丝点击