`
iffiffj
  • 浏览: 156747 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

JBOSS部署两个WAR包时相同的类出现java.lang.ClassCastException

阅读更多
1.对ClassCastException中文的解释是:
说JBOSS的WEB加载器默认是FALSE,根据配置文件的说明,其目的就是当出现多个加载器的时候,通过设定真假值来决定是否把JBOSS的WEB加载器作为统一的加载器。也就是说,如果在程序中特殊指明了某一个加载器,或者lib中用到了其它版本tomcat的JAR包,那么JBOSS自带的加载器设为FLASE,就会导致WAR包的JAR和类文件都没有被JBOSS的加载器加载。
2.解决办法:
把JBOSS自带的加载器由默认的FALSE改为TRUE。
3.解决细节:
修改jboss-4.2.3.GA/server/default/deploy/jboss-web.deployer/META-INF下的jboss-service.xml文件中的seJBossWebLoader属性改为true(默认是false)。
改后:
<attribute name="UseJBossWebLoader">true</attribute>

4.英文的解释:
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.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics