6 Replies Latest reply on Nov 4, 2003 3:02 PM by cwele

    Deploy the same EJB twice - nobody know ?!?

    cwele

      - Wheter is possible to deploy the same EJB - let say firstEJB ,with the same ejb-jar.xml,
      but with different jboss.xml - in two diff. ears ?
      I suppose yes, but <jndi-name> from within jboss.xml should differs, correct ?

      IF YES, then suppose I have first.ear, which contains
      firstWeb.war and firstEjb.jar

      AND second.ear, which contains
      someEjb.jar and _firstEjb.jar (the same as firstEjb.jar, but with different jboss.xml)

      - Servlet from the firstWeb.war uses some constant value for the InitialContent.lookup() - let say ejb/FirstEjb'- where looking up for the firstEjb (remote or local) reference

      - someEjb also uses the _same constant value ('ejb/FirstEjb') where looking up for firstEjb reference.

      Wheter is possible ?

        • 1. Re: Deploy the same EJB twice - nobody know ?!?

          Yes it's possible.

          jboss.xml to bind the two EJBs with different global names.

          You need to correctly map the private lookup name you use in servlets with jboss-web.xml file. That way they both may use the same constant value.

          -- Juha

          • 2. Re: Deploy the same EJB twice - nobody know ?!?
            cwele

            OK, then take a look at this:
            Here is part of my jboss.xml for that firstEjb , packaged into first.ear

            jboss.xml: (firstEjb.jar -> first.ear)

            <ejb-name>FirstEjb</ejb-name>
            <jndi-name>firstEar/FirstEjb</jndi-name>
            ...

            -the client for that firstEjb, web application (packaged along with that ejb in the first.ear) haves folloving ejb-ref:

            web.xml: (firstWeb.war -> first.ear)

            <ejb-ref>
            <ejb-ref-name>ejb/FirstEjb</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            ...
            ...
            </ejb-ref>

            jboss-web.xml: (firstWeb.war -> first.ear)

            <ejb-ref>
            <ejb-ref-name>ejb/FirstEjb</ejb-ref-name>
            <jndi-name>firstEar/FirstEjb</jndi-name>
            </ejb-ref>

            ======
            jboss.xml: (_firstEjb.jar -> second.ear)

            <ejb-name>FirstEjb</ejb-name>
            <jndi-name>secondEar/FirstEjb</jndi-name>
            ...

            -ejb client, another ejb (packaged along with that _firstEjb in the second.ear) haves folloving ejb-ref:

            ejb-jar.xml: (someEjb.jar -> second.ear)

            <ejb-ref>
            <ejb-ref-name>ejb/FirstEjb</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            ...
            ...
            </ejb-ref>

            jboss.xml: (someEjb.jar -> second.ear)

            <ejb-ref>
            <ejb-ref-name>ejb/FirstEjb</ejb-ref-name>
            <jndi-name>secondEar/FirstEjb</jndi-name>
            </ejb-ref>

            ----
            -In both cases (both clients uses, the same statement below)

            InitialContenxt.lookup('ejb/FirstEjb');

            throws NamingException : FirstEjb not bound !

            So, what is wrong ? I am totaly confused :(
            (Jboss 3.0.4)

            And, wheter is possible to achieve this goal if firstEjb have local interfaces, instead of Remote ?

            • 3. Re: Deploy the same EJB twice - nobody know ?!?

              try lookup on "java:comp/env/ejb/FirstEjb" instead

              • 4. Re: Deploy the same EJB twice - nobody know ?!?
                cwele

                -No, with

                java:comp/env/ejb/FirstEjb

                - the same thing happens :

                NamignException .. NameNotFoundExcepion FirstEjb not bound
                -------
                -Let make thing simple, suppose I have just one client for that firstEjb:

                here is part of my jboss.xml for that firstEjb , packaged into first.ear

                jboss.xml: (firstEjb.jar -> first.ear)

                <ejb-name>FirstEjb</ejb-name>
                <jndi-name>firstEar/FirstEjb</jndi-name>
                ...

                -the client for that firstEjb, web application (packaged along with that ejb in the first.ear) haves folloving ejb-ref

                web.xml: (firstWeb.war -> first.ear)

                <ejb-ref>
                <ejb-ref-name>ejb/FirstEjb</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>
                ...
                ...
                </ejb-ref>

                jboss-web.xml: (firstWeb.war -> first.ear)

                <ejb-ref>
                <ejb-ref-name>ejb/FirstEjb</ejb-ref-name>
                <jndi-name>firstEar/FirstEjb</jndi-name>
                </ejb-ref>

                ----
                Is this correct ? I think yes, but

                InitialContenxt.lookup('ejb/FirstEjb') AND
                InitialContenxt.lookup('java:comp/env/ejb/FirstEjb')

                both raises NameNotFoundException : FirstEjb not bound !

                -This is very strange, any other EJB server will not raise that exception.

                -So I think, this is impossible to achieve by JBoss server. The only way to do this, as I can see, is simple avoid

                <jndi-name>firstEar/FirstEjb</jndi-name>

                from jboss.xml for that firstEjb, and looking up with
                default ejb-name:

                ic.lookup('FirstEjb');

                - But, on that way, I cannot deploy that EJB twice ! (with different jboss.xml) :(((

                - Any other solution ?

                • 5. Re: Deploy the same EJB twice - nobody know ?!?
                  darranl

                  To find out exactly what is bound where :-

                  Goto http://localhost:8080/jmx-console
                  Click on the 'service=JNDIView' link
                  Invoke the 'java.lang.String list()' method.

                  You will be given the details of everything bound to JNDI without having to use trial and error to get the client to work.

                  • 6. Re: Deploy the same EJB twice - nobody know ?!?
                    cwele

                    -Thanks everyone for help.
                    After restarting JBoss, everything works just fine
                    (without any changes :((