3 Replies Latest reply on Oct 14, 2003 1:27 AM by frito

    Two JNDI names for one bean

    nebulosu

      How can a stateles session bean be deployed twice under different JNDI names?

      This is for the puropse of providing different datasources (resource-ref) for one bean implementation.

      Can it be done once in ejb-jar.xml and twice in the jboss.xml?

      The bean has a quite big description in the ejb-jar.xml and if this is duplicated it is getting hard to maintain. The container-transaction area for the mentioned bean is very big.

      Thank's in advance,
      Daniel

        • 1. Re: Two JNDI names for one bean

          You will need to duplicate configuration for the bean instance in your ejb-jar.xml file (and then the corresponding jndi-name mapping from two different EJB names to two separate JNDI names in jboss.xml).

          So there's no way around duplicating the config in the standard deployment descriptors. To avoid maintenance change issues you do not have to maintain and use the deployment descriptors directly in your source tree. It is possible to create XSL scripts that create the duplicates into ejb-jar.xml descriptors. This requires that you're somewhat familiar with the XML style sheets though.

          I use this myself to avoid writing and maintaining a lot of duplicate XML pieces for multiple deployments and configurations of the same bean. Unfortunately most scripts are specific to the bean implementations and not themselves reusable.

          -- Juha

          • 2. Re: Two JNDI names for one bean
            joa23

            Hi Juha,

            i had read some other postings about multiple instances of applications in one jboss.
            At least there is something that confuse me.
            You said is it not necessary to change any line of code.
            I'm asking my self how your jndi lookups do work in your code when you have configurable jndi names. Is there a trick? I'm using xdoclet and this tool is very cool. Since all the jndi Names are in the *Util class, may be xdoclet can help me? Do you have any hints for me?

            Thanks a lot!!!!
            Stefan

            • 3. Re: Two JNDI names for one bean
              frito

              Only use comp/env namespace in your code. The mapping from global or java: namespace to the comp/env namespace is done during deployment (resource tags in jboss.xml).

              Greetings,
              Frito