weblogic中使用java.lang.NoSuchMethodError解决办法

 在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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值