2008-05-21

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

关键字: java.lang.linkageerror
今天在做项目的时候,来了个奇怪的异常,具体异常如下:
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.
评论
发表评论

您还没有登录,请登录后发表评论

狂放不羁
  • 浏览: 72510 次
  • 性别: Icon_minigender_1
  • 来自: 厦门大学
  • 详细资料
搜索本博客
我的相册
E980bbdc-37d2-46cd-b0ba-38638405a1b7-thumb
Head first design patterns
共 29 张
存档
最新评论