6 Replies Latest reply on Apr 23, 2013 10:50 AM by lalitawasthi007

    Jboss As 7 JNDI binding for EJB

    lalitawasthi007

      Hello All

       

      I am migrating a code from AS 5.1 to 7.1

       

      I am trying to specify the JNDI binding for EJBs. According to the JIRA (https://issues.jboss.org/browse/AS7-3015?focusedCommentId=12651177&page=com.atlassian.jira.plugin.system.issuetabpanels%3acomment-tabpanel) I came to know that ejb-jar.xml is no longer work in jboss AS 7.1.

       

      I found that jboss-ejb3.xml can be used in place of this. Now my question is if I have a bean e.g. ConfigData and I want to bind it to the JNDI name java:comp/env/ejb/ConfigData .Kinldy let me know what changes needs to be done in the  jboss-ejb3.xml file.

       

      Thanks!!

       

      Regards

       

      Lalit

        • 1. Re: Jboss As 7 JNDI binding for EJB
          jaikiran

          Lalit Awasthi wrote:

           


          According to the JIRA (https://issues.jboss.org/browse/AS7-3015?focusedCommentId=12651177&page=com.atlassian.jira.plugin.system.issuetabpanels%3acomment-tabpanel) I came to know that ejb-jar.xml is no longer work in jboss AS 7.1.

          That's not true. That JIRA talks of jboss.xml (which was a JBoss specific deployment descriptor) and not about ejb-jar.xml.

           

           

          Lalit Awasthi wrote:

           

          Hello All

           

          Now my question is if I have a bean e.g. ConfigData and I want to bind it to the JNDI name java:comp/env/ejb/ConfigData .Kinldy let me know what changes needs to be done in the  jboss-ejb3.xml file.

           

          You don't need jboss-ejb3.xml for that. Binding to environment naming context (ENC) - java:comp  is one such namespace - can be done via EJB spec specified ejb-jar.xml. You'll have to take a look at the ejb-jar xsd for the right elements or someone who has a ready example, might be able to point you to it.

          1 of 1 people found this helpful
          • 2. Re: Jboss As 7 JNDI binding for EJB
            lalitawasthi007

            Thank you Jaikiran

             

            Let me explain the problem I am facing .

             

            Suppose I have a bean named ConfigDataBean and mentioned it in ejb-jar.xml and I am looking up it in the code .First thing that is confusing me is below output

             

            [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named ConfigData in deployment unit subdeployment "abcEJB.jar" of deployment "abc.ear" are as follows:

            java:global/abc/abcEJB/ConfigDataBean!com.test.IT.abc.ejb.session.ConfigDataHome
            java:app/abcEJB/ConfigDataBean!com.test.IT.abc.ejb.session.ConfigDataHome
            java:module/ConfigDataBean!com.test.IT.abc.ejb.session.ConfigDataHome
            java:jboss/exported/abc/abcEJB/ConfigDataBean!com.test.IT.abc.ejb.session.ConfigDataHome
            java:global/abc/abcEJB/ConfigDataBean!com.test.IT.abc.ejb.session.ConfigDataHome
            java:app/abcEJB/ConfigDataBean!com.test.IT.abc.ejb.session.ConfigDataHome
            java:module/ConfigDataBean!com.test.IT.abc.ejb.session.ConfigDataHome
            java:jboss/exported/abc/abcEJB/ConfigDataBean!com.test.IT.abc.ejb.session.ConfigDataHome

             

            Next thing when I am passing this (java:comp/env/ejb/ConfigDataBean) in the code and trying to look it up using below code

                       

                        InitialContext ctx = new InitialContext();
              
                        Object ref = ctx.lookup(ejbName);

             

            System.out.println(ctx.lookup(ejbName));

             

            It is giving me output "Proxy for remote EJB EJBHomeLocator{appName='abc', moduleName='abcEJB', distinctName='', beanName='ConfigDataBean', view='interface com.test.regit.abc.ejb.session.ConfigDataBeanHome'" it is cofusing me while the output should be  ConfigDataBeanHome .

             

            Kindly suggest.

             

            Thanks!!

             

             

            • 3. Re: Jboss As 7 JNDI binding for EJB
              sfcoy

              This looks like code that has been around for a while.

               

              In the "old" days, you looked up a "home" interface in JNDI and then use it's "create" method to get an instance of an EJB.

               

              In your case, you would invoking com.test.IT.abc.ejb.session.ConfigDataHome.create(...) to get your EJB.

               

              These "home" interfaces are not required in JEE5 or JEE6 compatible containers, but they are still supported.

              • 4. Re: Jboss As 7 JNDI binding for EJB
                lalitawasthi007

                Okay but now when I am trying to lookup it is giving me below output

                System.out.println(ctx.lookup(ejbName));

                 

                output "Proxy for remote EJB EJBHomeLocator{appName='abc', moduleName='abcEJB', distinctName='', beanName='ConfigDataBean', view='interface com.test.regit.abc.ejb.session.ConfigDataBeanHome'" it is cofusing me while the output should be  ConfigDataBeanHome .

                 

                Kindly suggest if I am doing anything wrong.

                 

                Actually I have the earlier code on JRE 6 and Jboss 5.1 and it is running fine

                 

                 

                • 5. Re: Jboss As 7 JNDI binding for EJB
                  sfcoy

                  If you mean "why the output should be ConfigDataBeanHome", then that is what I tried to explain above.

                   

                  Otherwise, I don't understand what you're trying to say.

                  • 6. Re: Jboss As 7 JNDI binding for EJB
                    lalitawasthi007

                    May be I could not understand.

                     

                    Actually I want the output as ConfigDataBeanHome in place of " Proxy for remote EJB EJBHomeLocator{appName='abc', moduleName='abcEJB', distinctName='', beanName='ConfigDataBean', view='interface com.test.regit.abc.ejb.session.ConfigDataBeanHome" in Jboss 7.1.

                     

                    Kindly suggest