关于jboss与j2ee1.4不友好的问题。

今天在做项目的时候,来了个奇怪的异常,具体异常如下:
java.lang.LinkageError: loader constraint violation: 

google了一会发现原来是jboss的类加载器的问题。因为同一个类被不同的类加载器所加载导致的,所以要按照一下步骤来修改几个配置文件就OK了。

First, edit the conf/jboss-service.xml file and set the NamingService CallByValue to true:


<mbean code="org.jboss.naming.NamingService"
name="jboss:service=Naming">
<!-- The call by value mode. true if all lookups are unmarshalled using
the caller's TCL, false if in VM lookups return the value by reference.
-->
<attribute name="CallByValue">true</attribute>

...
</mbean>





Second, edit the deploy/ear-deployer.xml file and set the Isolated and CallByValue attributes to true:



<server>
<!-- EAR deployer, remove if you are not using ear deployments -->
<mbean code="org.jboss.deployment.EARDeployer"
name="jboss.j2ee:service=EARDeployer">
<!-- A flag indicating if ear deployments should have their own scoped
class loader to isolate their classes from other deployments.
-->
<attribute name="Isolated">true</attribute>
<!-- A flag indicating if the ear components should have in VM call
optimization disabled.
-->
<attribute name="CallByValue">true</attribute>
</mbean>
</server>





Last, edit the deploy/jbossweb-tomcat50.sar/META-INF/jboss-service.xml file and set the Java2ClassLoadingCompliance and UseJBossWebLoader attributes to false:



<server>

<mbean code="org.jboss.web.tomcat.tc5.Tomcat5"
name="jboss.web:service=WebServer">

<!-- Get the flag indicating if the normal Java2 parent first class
loading model should be used over the servlet 2.3 web container first
model.
-->
<attribute name="Java2ClassLoadingCompliance">false</attribute>

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

<!-- A flag indicating if the JBoss Loader should be used. This loader
uses a unified class loader as the class loader rather than the tomcat
specific class loader.
-->
<attribute name="UseJBossWebLoader">false</attribute>

...




注意:如果是在jboss-4.2.1.GA下,第三步可以不用改了,默认就是false.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值