5 Replies Latest reply on May 7, 2013 4:11 AM by jaikiran

    InitialContext for ejb lookup locally in Jboss as 7.1.3 Final

    georgesg

      I am migrating EJB2.1 from jboss 4.3 to Jboss 7.1.3 Final.

       

      For RMI lookup , i am using "ejb client" project  and during this lookup i need to use provider url, package prefix and Initial Context Factory.

       

      How about local ejb lookup within the same module or within the application ?  Should we still go through ejbClient api incase of ejb2.1 local lookup ?

        • 1. Re: InitialContext for ejb lookup locally in Jboss as 7.1.3 Final
          jaikiran

          Local lookup doesn't require EJB client protocol (ejb: ). ejb: is only meant for remote views.

          • 2. Re: InitialContext for ejb lookup locally in Jboss as 7.1.3 Final
            georgesg

            So, for local lookup using ejb 2.1, i can do the lookup as below ?

             

            InitialContext context = new InitialContext();

            Object = context.lookup("java:app/MobilematrixCX_ejb-1.0.0-SNAPSHOT/com.cassis.cx.base.Dispatcher!com.cassis.cx.base.Dispatcher_LocalHome");

             

            Earlier in Jboss 4.3, we set the below values for Initial Context,

             

            <initial-context name="PX">

                    <name-value-pair>

                        <name>java.naming.factory.initial</name>

                        <value>org.jnp.interfaces.NamingContextFactory</value>

                    </name-value-pair>

                    <name-value-pair>

                        <name>java.naming.provider.url</name>

                        <value>jnp://127.0.0.1:21119</value>

                    </name-value-pair>

                    <name-value-pair>

                        <name>java.naming.factory.url.pkgs</name>

                        <value>org.jboss.naming:org.jnp.interfaces</value>

                    </name-value-pair>

                </initial-context

            • 3. Re: InitialContext for ejb lookup locally in Jboss as 7.1.3 Final
              jaikiran

              Yes, you can use the java:global, java:app, java:module namespaces as defined by the spec. In fact, you can even use those namespaces for remote EJB views, if the EJB is deployed on the same server as the client.

              • 4. Re: InitialContext for ejb lookup locally in Jboss as 7.1.3 Final
                georgesg

                Thanks Jaikiran.

                 

                Now am clear on JNDI lookup. But my primary confusion is with regard to the Initial context Instantiation. Because, if you look at the below InitialContext parameters, In Jboss 4.3.GA , they use "JNP" protocol for Package Prefix as well as for Initial Context Factory. So, when i Instantiate InitialContext in JBOSS EAP 6 (7.1.3 Final) , How will i do Instantiation of InitialContext for a local lookup ?  Should i need to instantiate something like  below or just  InitialContext context = new InitialContext();  will do the job ?

                 

                 

                <initial-context name="PX">

                        <name-value-pair>

                            <name>java.naming.factory.initial</name>

                            <value>org.jnp.interfaces.NamingContextFactory</value>

                        </name-value-pair>

                        <name-value-pair>

                            <name>java.naming.provider.url</name>

                            <value>jnp://127.0.0.1:21119</value>

                        </name-value-pair>

                        <name-value-pair>

                            <name>java.naming.factory.url.pkgs</name>

                            <value>org.jboss.naming:org.jnp.interfaces</value>

                        </name-value-pair>

                    </initial-context

                • 5. Re: InitialContext for ejb lookup locally in Jboss as 7.1.3 Final
                  jaikiran

                  ANAND KUMAR GEORGE PREM KUMAR wrote:

                   

                  just  InitialContext context = new InitialContext();  will do the job ?

                   

                  Yes that should work.