一个关于java.lang.ClassCastException: $Proxy65的错误解决办法

错误描述:

今天用jsp调用一个会话bean的时候,出现了一个“java.lang.ClassCastException: $Proxy65”的错误,百度了一下,中文的解释是:

说JBOSS的WEB加载器默认是FALSE,根据配置文件的说明,其目的就是当出现多个加载器的时候,通过设定真假值来决定是否把JBOSS的WEB加载器作为统一的加载器。也就是说,如果在程序中特殊指明了某一个加载器,或者lib中用到了其它版本tomcat的JAR包,那么JBOSS自带的加载器设为FLASE,就会导致WAR包的JAR和类文件都没有被JBOSS的加载器加载。

解决办法:

把JBOSS自带的加载器由默认的FALSE改为TRUE。

解决细节:

修改jboss-4.2.3.GA/server/default/deploy/jboss-web.deployer/META-INF下的jboss-service.xml文件中的

seJBossWebLoader属性改为true(默认是false)。

改后:

<attribute name="UseJBossWebLoader">true</attribute>

 

下面是一段英文的解释:

 

See ClassLoadingConfiguration.

Available option in deploy/jbossweb-tomcat.sar/META-INF/jboss-service.xml

or deploy/jboss-web.deployer/META-INF/jboss-service.xml

This configuration options toggles usage of separate classloaders for web modules. The JBoss unified classloader holds all the classes from multiple web applications in one big classloader and may cause unwanted interference.

Example

Imagine web modules "sales.war" and "stock.war", both containing some version of "utility.jar". In case "sales.war" uses version 1.0 and "stock.war" requires version 2.0, turning off the unified web loader is the safest solution. If you don't, the first loaded library will have priority, and remains in the classloader till the reference count drops to zero.

The disadvantage of using isolated classloaders: either you need to duplicate the same library across multiple web modules, or add it to the classpath of your server instance (default: lib/). The instance libraries are defaults, they can be overridden when the web module contains it's own custom versions.

The configuration file contains a small comment about isolation of JSP files as well, to separate two JSP files with the same name from two different web modules. In JBoss 4.0.5, using non-precompiled JSP pages, this seems to work fine, even with the JBoss unified web loader.

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值