0 Replies Latest reply on Mar 2, 2010 6:38 AM by Marco Benuzzi

    How to force per application call-by-value

    Marco Benuzzi Newbie

      I've two application (app1 and app2) packaged as ear (ear1 and ear2).

      An EJB in app1 lookup and use two EJB in app2.

      The Remote interfaces and the serializable transfer objects are in app2-client.jar

      I'm using JBoss AS 5.0

       

      ear1.ear

        |-- app2-client.jar

        |-- app1-ejb.jar

        |-- app1.war

        |-- ...


      ear2.ear

        |-- app2-ejb.jar

        |-- app2.war

        |-- ...

        |-- lib

             |-- app2-client.jar

       

      If I deploy ear1 and ear2 on two different server all is working fine.

       

      If I deploy ear1 and ear2 on the same server (using isolation with two different <loader-repository> in jboss-app.xml) I found a very strange behaviour:

      EJB1 in ear1 lookup and use EJB-A in ear2 and works fine

      EJB1 in ear1 lookup and use EJB-B in ear2, but gets java.lang.ClassCastException ($Proxy426 cannot be cast to org.question.EJBBRemote): the lookup return a valid proxy to EJB-B, but the cast to the Remote interface fails.

      The only way to make the deployment work is to remove app2-client.jar from all the ears and put in jbossas/server/default/lib.

       

      In my ear deployer configuration (ear-deployer-jboss-beans.xml) I've:

      <property name="callByValue">false</property>
      <property name="isolated">true</property>

      I want this configuration because I need call-by-reference between EJBs in the same ear.

       

      The problem COULD BE that the lookup of the remote interface in the one server deployment (same JVM) return a reference (call-by-rerefernce) even if the EJBs are in separete isolated ear, so the cast fails because I've the same class in two different classloader.

       

      Questions:

      1) Why I can use only one of my EJBs in ear2? How can I investigate what is the issue?

       

      2) Is there a way to create an initial context and force a lookup with call-by-value between separate isolated ear? (I don't want to put application jars into jbossas/server/default/lib)