1 Reply Latest reply on Sep 19, 2002 12:54 PM by Adrian Brock

    ejb-ref confusion

    Matthew Parrish Newbie

      Hello everyone. I'm trying to create two builds of my project, one for production and one for development. What I want to do is deploy both .ear files in the same server. The two builds will have different xml descriptors that give the ejb's different jndi-names for the two deployments. But what happens is that when I deploy both apps, they both use the ejb's of whichever app was deployed first.

      Here's part of my xml files

      ejb-jar (1)


      <ejb-name>Stats</ejb-name>
      com.sark.sarkffl.ejb.stats.StatsHome
      com.sark.sarkffl.ejb.stats.Stats
      <ejb-class>com.sark.sarkffl.ejb.stats.StatsBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-ref>
      <ejb-ref-name>ejb/Schedule</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      com.sark.sarkffl.ejb.schedule.ScheduleHome
      com.sark.sarkffl.ejb.schedule.Schedule
      <ejb-link>Schedule</ejb-link>
      </ejb-ref>


      jboss (1)


      <ejb-name>Stats</ejb-name>
      <jndi-name>sarkfflEJB/Stats</jndi-name>


      ejb-jar (2)


      <ejb-name>StatsDev</ejb-name>
      com.sark.sarkffl.ejb.stats.StatsHome
      com.sark.sarkffl.ejb.stats.Stats
      <ejb-class>com.sark.sarkffl.ejb.stats.StatsBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-ref>
      <ejb-ref-name>ejb/Schedule</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      com.sark.sarkffl.ejb.schedule.ScheduleHome
      com.sark.sarkffl.ejb.schedule.Schedule
      <ejb-link>ScheduleDev</ejb-link>
      </ejb-ref>


      jboss (2)


      <ejb-name>StatsDev</ejb-name>
      <jndi-name>sarkfflEJBDev/StatsDev</jndi-name>


      Servlet (1)

      calls lookup("sarkfflEJB/Stats");

      Servlet (2)

      calls lookup("sarkfflEJBDev/StatsDev");

      Why do I get the same ejb when called by either app?

        • 1. Re: ejb-ref confusion
          Adrian Brock Master

          To deploy the same class names twice in 3.x you
          need to use the scoped ear classloader.

          Put your beans in different ears and add a jboss-app.xml
          to the META-INF alongside application.xml

          <jboss-app>
          <loader-repository>sark:loader=stats</loader-repository>
          </jboss-app>

          and

          <jboss-app>
          <loader-repository>sark:loader=statsdev</loader-repository>
          </jboss-app>

          Recent discussions concluded that scoped classloading
          will be the default in 3.2 and it won't just be
          restricted to ears.

          Regards,
          Adrian