14 Replies Latest reply on Sep 3, 2008 12:28 PM by William Anez

    Multiples Jars with same EJBs

    William Anez Newbie

      Hi, i have a simple project with a single EJB, im writing the ejb-jar.xml file and i have all the little app working well, but i need to create several jars with same architecture but different behaviors, so on my little experiment i have a Bean with a single method, the method only print "Hello From Jar", im creating 2 jars of this kind, and the only thing im changing is:

      The string that is printed, and the <ejb-name> on the ejb-jar.xml files, for example:

      On Jar test-ejb-1.jar i have the string "Hello From Jar 1" and the <ejb-name>: test-ejb-1
      On Jar test-ejb-2.jar the string "Hello From Jar 2" and the <ejb-name>: test-ejb-2

      Also i have a simple client that try to get the responses from the ejbs, whit a code like follows:

      callZoneMethod("test-ejb-1/remote"); //This perfom the InitialContext operations.
      callZoneMethod("test-ejb-2/remote"); //This perfom the InitialContext operations.

      But in the jboss logs always get call one of the EJB, no matter the resource im using for the lookup.

      Anyone has any idea ? i need to implement this for my applications, i need to have multiples mini-apps with the same clases, only with diferents variants inside the methods that the ejbs are defining.

      Im using Jboss 4.2.2

      I hope anyone could help me.

        • 1. Re: Multiples Jars with same EJBs
          Peter Johnson Master

          Please post the source code for your EJBs, and for any EJB configuration files. Also post the output from running listAll on the JNDIView (see http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/Server_Configuration_Guide/Additional_Naming_MBeans-The_org.jboss.naming.JNDIView_MBean.html)

          Also post the client code used to access the EJBs (I assume this would be the body of the callZoneMethod() method)

          Make sure to enclose the source code and XML text within code tags (select the text and click the Code button under the editor window).

          • 2. Re: Multiples Jars with same EJBs
            William Anez Newbie

            Code of the EJB (with real names)

            Interface:

            package com.ogangi.mimapp3.zone.bean;
            
            import javax.ejb.Remote;
            
            /**
             * Author: cucho
             * Created on: Aug 29, 2008
             **/
            @Remote
            public interface Zone {
            
             public String sayHello();
            
            }
            


            Bean:
            package com.ogangi.mimapp3.zone.bean;
            
            import javax.ejb.Stateless;
            
            import com.ogangi.mimapp3.zone.logger.MimappLogger;
            
            /**
             * Author: cucho
             * Created on: Aug 29, 2008
             **/
            @Stateless
            public class ZoneBean implements Zone {
            
             private static final String logTag = "ZoneBean";
            
             public String sayHello() {
            
            // MimappLogger.info(logTag, "Hello from ZoneBean ?");
             System.out.println("miami");
            
             return "Hello from ZoneBean";
             }
            
            }
            


            ejb-jar.xml for the first jar

            <?xml version="1.0"?>
            <ejb-jar>
             <description>Mimapp3 Zone Miami</description>
             <display-name>M3Z Miami</display-name>
             <enterprise-beans>
            
             <session>
             <ejb-name>m3z-miami-zone-bean</ejb-name>
             <remote>com.ogangi.mimapp3.zone.bean.Zone</remote>
             <ejb-class>com.ogangi.mimapp3.zone.bean.ZoneBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Bean</transaction-type>
             </session>
             </enterprise-beans>
            </ejb-jar>
            


            ejb-jar.xml for the second jar
            <?xml version="1.0"?>
            <ejb-jar>
             <description>Mimapp3 Zone Venezuela</description>
             <display-name>M3Z Venezuela</display-name>
             <enterprise-beans>
            
             <session>
             <ejb-name>m3z-venezuela-zone-bean</ejb-name>
             <remote>com.ogangi.mimapp3.zone.bean.Zone</remote>
             <ejb-class>com.ogangi.mimapp3.zone.bean.ZoneBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Bean</transaction-type>
             </session>
             </enterprise-beans>
            </ejb-jar>
            


            output from running listAll on the JNDIView
            Web Applications
            
            java:comp namespace of the TestApp.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the jboss-web.deployer/ROOT.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the echopointngtest.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the InteractiveTest.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the jmx-console.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the jbossws.sar/jbossws-context.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the deploy-hasingleton/jbossmq-httpil.sar/jbossmq-httpil.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/jbossmq/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the juddi-service.sar/juddi.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- jdbc (class: org.jnp.interfaces.NamingContext)
             | | +- juddiDB[link -> java:/DefaultDS] (class: javax.naming.LinkRef)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the httpha-invoker.sar/invoker.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/jmx-console/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
            
            
            java:comp namespace of the console-mgr.sar/web-console.war application:
            
             +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
             +- ORB (class: org.jacorb.orb.ORB)
             +- env (class: org.jnp.interfaces.NamingContext)
             | +- security (class: org.jnp.interfaces.NamingContext)
             | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
             | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
             | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)
            
            
            java: Namespace
            
             +- mimapp3 (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- jaas (class: javax.naming.Context)
             | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
             | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
             | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
             +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
             +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
             +- comp.ejb3 (class: javax.naming.Context)
             | NonContext: null
             +- JBossCorbaNaming (class: org.omg.CosNaming.NamingContextExt)
             +- m3z-miami (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
             +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
             +- JBossCorbaPOA (class: org.omg.PortableServer.POA)
             +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
             +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
             +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
             +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
             +- JBossCorbaInterfaceRepositoryPOA (class: org.omg.PortableServer.POA)
             +- Mail (class: javax.mail.Session)
             +- comp.original (class: javax.namingMain.Context)
             +- JBossCorbaORB (class: org.omg.CORBA.ORB)
             +- timedCacheFactory (class: javax.naming.Context)
            Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
             +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
             +- m3z-venezuela (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
             +- comp (class: javax.naming.Context)
            
            
            Global JNDI Namespace
            
             +- ZoneBean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy162 implements interface com.ogangi.mimapp3.zone.bean.Zone,interface org.jboss.ejb3.JBossProxy)
             +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
             +- HAPartition (class: org.jnp.interfaces.NamingContext)
             | +- DefaultPartition (class: org.jboss.ha.framework.server.HAPartitionImpl)
             +- SmsServerFacadeManagerBean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy125 implements interface com.ogangi.mimapp3.beans.SmsServerFacadeManager,interface org.jboss.ejb3.JBossProxy)
             +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
             +- queue (class: org.jnp.interfaces.NamingContext)
             | +- A (class: org.jboss.mq.SpyQueue)
             | +- testQueue (class: org.jboss.mq.SpyQueue)
             | +- ex (class: org.jboss.mq.SpyQueue)
             | +- DLQ (class: org.jboss.mq.SpyQueue)
             | +- D (class: org.jboss.mq.SpyQueue)
             | +- C (class: org.jboss.mq.SpyQueue)
             | +- B (class: org.jboss.mq.SpyQueue)
             +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
             +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
             +- JAXR (class: org.apache.ws.scout.registry.ConnectionFactoryImpl)
             +- RouterBean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy122 implements interface com.ogangi.mimapp3.beans.Router,interface org.jboss.ejb3.JBossProxy)
             +- m3z-miami-zone-bean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy145 implements interface com.ogangi.mimapp3.zone.bean.Zone,interface org.jboss.ejb3.JBossProxy)
             +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
             +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
             +- DestinationOperationsBean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy116 implements interface com.ogangi.mimapp3.beans.DestinationOperations,interface org.jboss.ejb3.JBossProxy)
             +- UserTransactionSessionFactory (proxy: $Proxy14 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
             +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
             +- MMTRouterBean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy159 implements interface com.ogangi.mimapp3.zone.bean.MMTRouter,interface org.jboss.ejb3.JBossProxy)
             +- console (class: org.jnp.interfaces.NamingContext)
             | +- PluginManager (proxy: $Proxy57 implements interface org.jboss.console.manager.PluginManagerMBean)
             +- persistence.units:jar=mimapp3-app-server.jar,unitName=mimapp3 (class: org.hibernate.impl.SessionFactoryImpl)
             +- m3z-venezuela-zone-bean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy162 implements interface com.ogangi.mimapp3.zone.bean.Zone,interface org.jboss.ejb3.JBossProxy)
             +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
             +- topic (class: org.jnp.interfaces.NamingContext)
             | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
             | +- testTopic (class: org.jboss.mq.SpyTopic)
             | +- securedTopic (class: org.jboss.mq.SpyTopic)
             +- persistence.units:jar=m3z-venezuela.jar,unitName=m3z-venezuela (class: org.hibernate.impl.SessionFactoryImpl)
             +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
             +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
             +- HASessionState (class: org.jnp.interfaces.NamingContext)
             | +- Default (class: org.jboss.ha.hasessionstate.server.HASessionStateImpl)
             +- ControllerBean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy113 implements interface com.ogangi.mimapp3.beans.Controller,interface org.jboss.ejb3.JBossProxy)
             +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
             +- invokers (class: org.jnp.interfaces.NamingContext)
             | +- gilthanas (class: org.jnp.interfaces.NamingContext)
             | | +- iiop (class: org.jboss.invocation.iiop.IIOPInvoker)
             +- MMTControllerBean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy156 implements interface com.ogangi.mimapp3.zone.bean.MMTController,interface org.jboss.ejb3.JBossProxy)
             +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
             +- jmx (class: org.jnp.interfaces.NamingContext)
             | +- invoker (class: org.jnp.interfaces.NamingContext)
             | | +- RMIAdaptor (proxy: $Proxy56 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
             | +- rmi (class: org.jnp.interfaces.NamingContext)
             | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
             +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
             +- persistence.units:jar=m3z-miami.jar,unitName=m3z-miami (class: org.hibernate.impl.SessionFactoryImpl)
             +- MMCOperationsBean (class: org.jnp.interfaces.NamingContext)
             | +- remote (proxy: $Proxy119 implements interface com.ogangi.mimapp3.beans.MMCOperations,interface org.jboss.ejb3.JBossProxy)
             +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
            
            
            HA-JNDI Namespace
            
            
            
            


            client who invoke the ejb:
            package com.ogangi.mimapp3.zone.test;
            
            import java.util.Set;
            
            import javax.management.MBeanServerConnection;
            import javax.management.ObjectInstance;
            import javax.management.ObjectName;
            import javax.naming.InitialContext;
            
            import com.ogangi.mimapp3.zone.bean.MMTRouter;
            import com.ogangi.mimapp3.zone.bean.Zone;
            
            
            /**
             * Author: cucho
             * Created on: Aug 29, 2008
             **/
            public class ZoneTest {
            
            
             public ZoneTest() {
             System.out.println("Start");
            
             callZoneMethod("m3z-miami-zone-bean/remote");
             callZoneMethod("m3z-venezuela-zone-bean/remote");
            
             System.out.println("End");
             }
            
             public void callZoneMethod(String resourceName) {
            
             try {
            
             InitialContext ctx = new InitialContext();
            
             Zone zone = (Zone) ctx.lookup(resourceName);
             zone.sayHello();
            
            
             } catch (Exception e) {
             e.printStackTrace();
             }
            
             }
            
             public void list() {
            
             try {
             InitialContext ctx = new InitialContext();
             MBeanServerConnection mbs = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
            
             ObjectName filterName = new ObjectName("");
             Set<ObjectInstance> objectNames = mbs.queryMBeans(filterName, null);
            
             for (ObjectInstance objectInstance : objectNames) {
             String name = objectInstance.getObjectName().getCanonicalName();
             if (name.contains("m3z")) {
             System.out.println(name);
             }
             }
            
             } catch (Exception e) {
             e.printStackTrace();
             }
            
             }
            
             public static void main(String[] args) {
            
             new ZoneTest();
            
             }
            
            }
            



            I hope this helps, thx for you fast reply.

            • 3. Re: Multiples Jars with same EJBs
              Peter Johnson Master

              I think you are running into a classloader issue. First one EJB gets initiated, which loads the Zone and ZoneBean classes. Then when the second EJB is being initiated, the classloader notes that the classes defined by the EJBs descriptor have already been loaded.

              The only way I can think of to separate them is to place each EJB JAR file into its own EAR file and define a classloader repository to keep the classes separate. Of course, then you will also have to place the code that accesses the EJBs into those EAR files, and that code can access only the EJB found in that EAR (it cannot access the EJB in the other EAR).

              Of course, this is just my understanding. Someone else might know more.

              • 4. Re: Multiples Jars with same EJBs
                jaikiran pai Master

                I haven't yet given this example a try, but i think this should have worked. Are you sure that these 2 jars files do contain 2 "different implementations" of the ZoneBean? Just to rule out any issues with your build script, can you check that the class files in these 2 jars have different implementation? Maybe the build is just copying the same ZoneBean class file to both the jars?

                • 5. Re: Multiples Jars with same EJBs
                  William Anez Newbie

                  Thanks for your time Peter.

                  Jaikiran, im absolutely sure that the both EJB have different implementations, im working with eclipse and i have only one project, in that project i have 2 ants, the ants only copy the class files and make the jar so, i go to the sayHello y change the string just adding the word "miami", complie and run the miami ant, then i change again the string for "venezuela", compile and run the venezuela ant.

                  To be absoletely sure i am decompiling the jars and i get the differents string to print, so the jars have differents implementations.

                  I think this is possible to do too, i just dont get why is not working, im trying to get a solution too, the documentation says that each jar is independent, thats why this sould work.

                  I apreciate any ideas or things to test here.

                  • 6. Re: Multiples Jars with same EJBs
                    William Anez Newbie

                    Interes Behavior, maeby this give us a clue.

                    i have only 2 jars, miami one and venezuela one, so imagine this scenario:

                    I have running and deployed the jboss and the jars, in the miami jar i have the string "miami2" and in the venezuela jar i have the string "venezuela2" so i decide to compile two new jars and overwrite the existing, so the jboss is going to load them again.

                    I make this two new jars, miami with string "miami" and venezuela with string "venezuela" and i run the test with this order:

                    callZoneMethod("m3z-miami-zone-bean/remote");
                    callZoneMethod("m3z-venezuela-zone-bean/remote");
                    


                    im just about to call Obi One (you are our last hope) :P
                    I mean, calling first miami and then venezuela, but surpriselly i have this output on the server:

                    2008-09-03 07:41:19,884 INFO [STDOUT] venezuela2
                    2008-09-03 07:41:19,919 INFO [STDOUT] miami
                    


                    for the first call (miami one) the bean responding is and old one, one that is suposed not to be here at this time and is venezuela...

                    for the second call (venezuela one) i have response from one new bean but the miami one instead of venezuela.

                    at this point i stop the jboss, and start it again, so he is gonna to load all again from the beginning, i run the test and get:

                    2008-09-03 07:50:40,702 INFO [STDOUT] miami
                    2008-09-03 07:50:40,728 INFO [STDOUT] miami
                    


                    • 7. Re: Multiples Jars with same EJBs
                      jaikiran pai Master

                      Now that you have confirmed that this is not a build related issue, let me see how it behaves on my local setup.

                      • 8. Re: Multiples Jars with same EJBs
                        jaikiran pai Master

                         

                        "PeterJ" wrote:
                        I think you are running into a classloader issue. First one EJB gets initiated, which loads the Zone and ZoneBean classes. Then when the second EJB is being initiated, the classloader notes that the classes defined by the EJBs descriptor have already been loaded.


                        Peter is right. That's exactly what's happening. I tested a similar setup with verbose classloading enabled. And it showed that the bean interface and the bean implementation classes are loaded only once when the first jar is being parsed. As a result, only one implementation gets used.

                        So as Peter suggested, you will have to:

                        "PeterJ" wrote:

                        The only way I can think of to separate them is to place each EJB JAR file into its own EAR file and define a classloader repository to keep the classes separate. Of course, then you will also have to place the code that accesses the EJBs into those EAR files, and that code can access only the EJB found in that EAR (it cannot access the EJB in the other EAR).




                        • 9. Re: Multiples Jars with same EJBs
                          William Anez Newbie

                          Really thanks for your help, im giving a try to the EAR, i have one already deployed with all my structure but it seems not to starting the EJB and bounding it to the JNDI, can you recomend me any online example, i think im missing something on my ear file or in the configuration, only get on the jboss logs this:

                          2008-09-03 10:52:25,969 INFO [org.jboss.deployment.EARDeployer] Init J2EE application: file:/opt/jboss-4.2.2.GA/server/all/deploy/mimapp3/m3z-miami.ear
                          2008-09-03 10:52:26,016 INFO [org.jboss.deployment.EARDeployer] Started J2EE application: file:/opt/jboss-4.2.2.GA/server/all/deploy/mimapp3/m3z-miami.ear
                          


                          But i cant call the Bean, and is not on the jmx-console of jboss, im sure i am missing something.

                          Thanks again for the help.

                          • 10. Re: Multiples Jars with same EJBs
                            jaikiran pai Master

                            What does the following command output?

                            jar -tf m3z-miami.ear


                            Also, have you made a ejb module entry in the application.xml in your EAR?


                            can you recomend me any online example, i think im missing something on my ear file or in the configuration


                            I would have recommended the EJB3Trail at http://trailblazer.demo.jboss.com/EJB3Trail/, but for some reason it's been down since many days.

                            Here's how i would package the application in an EAR:
                            m3z-miami.ear
                             |
                             |--- META-INF
                             | |
                             | |--- application.xml
                             | |
                             | |--- jboss-app.xml
                             |
                             |
                             |--- miami-ejb.jar
                             | |
                             | |--- META-INF
                             | | |
                             | | |--- ejb-jar.xml
                             | |
                             | |
                             | |--- [the ejb related classes]
                             |
                             |
                             |--- MyApp.war (if you have any war files)
                             | |
                             | |--- WEB-INF
                             | | |
                             | | |--- classes
                            
                            


                            The application.xml, in the META-INF folder of the EAR, would then look like:

                            <?xml version="1.0" encoding="UTF-8"?>
                            
                            <application>
                             <display-name>miami</display-name>
                            
                             <module>
                             <ejb>miami-ejb.jar</ejb>
                             </module>
                            
                             <!-- If any WAR files, then map them -->
                             <module>
                             <web>
                             <web-uri>MyApp.war</web-uri>
                             <context-root>/MyApp</context-root>
                             </web>
                             </module>
                            
                            </application>
                            

                            The jboss-app.xml (for classloading configuration):
                            <jboss-app>
                            
                             <loader-repository>
                             miami:loader=MiamiClassloader
                             <loader-repository-config>
                             java2ParentDelegation=false
                             </loader-repository-config>
                             </loader-repository>
                            
                            </jboss-app>








                            • 11. Re: Multiples Jars with same EJBs
                              William Anez Newbie

                              Thanks, i have the deployment correctly now, i let you know the next step in a while (when i have two ears and i has edited the ear-deploymen.jar)

                              • 12. Re: Multiples Jars with same EJBs
                                Peter Johnson Master

                                Did you remember to provide a META-INF/application.xml file and in there reference your EJB JAR?

                                • 13. Re: Multiples Jars with same EJBs
                                  Peter Johnson Master

                                  Sorry, only saw page 1 of this topic...

                                  • 14. Re: Multiples Jars with same EJBs
                                    William Anez Newbie

                                    Yes, i remember that, i have some background working with jboss, this is not too new for me (i have my mistakes too :) ), and im glad to announce that ALL is working just fine, i have my two ear files whit their application.xml and ejb-jar and the jar itself deployed in the jboss, i modifi the ear-deployment.xml to enable the isolate, and modify my test to add the sub-name on the jndi (for each ear) like this:

                                    callZoneMethod("m3z-miami/m3z-miami-zone-bean/remote");
                                     callZoneMethod("m3z-venezuela/m3z-venezuela-zone-bean/remote");
                                    


                                    And when a run all i finally get in my logs:

                                    2008-09-03 11:49:03,293 INFO [STDOUT] miami
                                    2008-09-03 11:49:03,309 INFO [STDOUT] venezuela
                                    


                                    And i found this way a lot better that my fisrt idea, because i can now have war inside for each zone ;) and all working later in a cluster enviroment.

                                    I have no word to thank you guy, really thx for you help, was very helpfull and i appreciate a lot that.