7 Replies Latest reply on Apr 24, 2006 9:03 AM by marcreis

    EJB 3.0, JBoss 4.0.4.RC2 JNDI Binding

    marcreis

      Hi, I am new to JBoss, EJB3.0 and Co. (So the solution might be simpler, since I might oversee something in the config)
      I just tryed to move a simple test app from 4.0.3.sp1 to 4.0.4.RC2.
      The Problem I am having now ist that I get a different naming in the JNDI Tree and I have no idea why. The JNDI Tree:
      4.0.3sp1

      ...
      +- de.home.test.interfaces.INatPersLstLocal (proxy: $Proxy65 implements interface de.mediacare.test.interfaces.INatPersLstLocal,interface org.jboss.ejb3.JBossProxy)
      +- de.home.test.interfaces.INatPersLstRemote (proxy: $Proxy64 implements interface de.mediacare.test.interfaces.INatPersLstRemote,interface org.jboss.ejb3.JBossProxy)
      ...
      


      4.0.4rc2
      ...
      +- NatPerLstBean (class: org.jnp.interfaces.NamingContext)
       | +- local (proxy: $Proxy67 implements interface de.home.test.interfaces.INatPersLstLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
       | +- remote (proxy: $Proxy66 implements interface de.home.test.interfaces.INatPersLstRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
      ...
      


      So when I try to fecht the context with
      ...
      InitialContext initCtx = new InitialContext();
       NamingEnumeration myNamingEnum = initCtx.list(initCtx.getNameInNamespace());
      
       INatPersLst persLstI = (INatPersLst)initCtx.lookup(de.home.test.interfaces.INatPersLstRemote.class.getName());
      ...
      

      nothing is found.
      What am I overseening ?

      Thx ahead !

        • 1. Re: EJB 3.0, JBoss 4.0.4.RC2 JNDI Binding
          anders.hedstrom
          • 2. Re: EJB 3.0, JBoss 4.0.4.RC2 JNDI Binding
            marcreis

            Hi first off, thanks for the link. I checked it out, but...
            Unfortunately it doesn?t clarify to me why the behaviour of the JNDI Binding/Naming changed for my code when deploying in 4.0.3SP1 (where it works) or 4.0.4.RC2 (where it does not work).
            I have, of course, checked all config files I know of (or could find) and the doc?s, but I don?t see why the behaviour has changed (of course I could have overseen something or looked at the wrong spots of the doc?s).

            Is it suggested to always defined your own local/remote binding/naming so that you don?t run into this?

            • 3. Re: EJB 3.0, JBoss 4.0.4.RC2 JNDI Binding
              anders.hedstrom

              You do a look up on the remote interface class name

              INatPersLst persLstI = (INatPersLst)initCtx.lookup(de.home.test.interfaces.INatPersLstRemote.cla
              ss.getName());
              this was the default jndi binding in previous versions of the jboss ejb3 implementation. Now your ejb3 is bound to <ejb-name>/remote. If your ejb3 is packaged inside a ear the ear name is prepended, <ear-name>/<ejb-name>/remote



              • 4. Re: EJB 3.0, JBoss 4.0.4.RC2 JNDI Binding
                marcreis

                Thx for the fast help !

                I did it like this, since a direct lookup (NatPersLstBean/remote) didnt seem to work, but this does the job:

                ...
                Object xyz = initCtx.lookup("NatPerLstBean");
                NamingContext myNamingContext = (NamingContext)xyz;
                xyz = myNamingContext.lookup("remote");
                INatPersLst persLstI = (INatPersLst)xyz;
                ...
                



                • 5. Re: EJB 3.0, JBoss 4.0.4.RC2 JNDI Binding
                  marcreis

                  This might actually rather fit into the JNDI area, but since I?m not sure, I'll use this thread to continue my questioning:
                  The Problem that I am having is concerning the binding into the JNDI Tree via annotations:
                  After the new naming schema in 4.0.4.RC2 ( RC6 EJB 3.0), my objects get hung as "objectname/remote" and ?objectname/local? into the JNDI Tree.
                  Before I used too look up the remote interface using:

                  INatPersLst persLstI = (INatPersLst)initCtx.lookup(INatPersLstRemote.class.getName());
                  

                  So now, I thought , I could look it up like this (I dont really like to hard code the name)
                  String jndiName = ((RemoteBinding)INatPersLstRemote.class.getAnnotation(RemoteBinding.class)).jndiBinding(); Object xyz = initCtx.lookup(jndiName);
                  

                  I stated in the remote interface the annotation
                  @RemoteBinding(jndiBinding="de.somewhere.test.interfaces.INatPersLstRemote")
                  

                  as the name to use in the JNDI Tree (or at least that is what I expected), but unfortunately that is not the name with which it gets hung into the JNDI Tree, there it is still named "NatPersLstBean/remote".

                  Is there some config I missed that enables/disables the renaming of the JNDI Binding in some config file?
                  And/or is there a better non static way of fetching/naming for the interface name and doing this lookup?

                  Thx !

                  • 6. Re: EJB 3.0, JBoss 4.0.4.RC2 JNDI Binding
                    marcreis

                    Ok, I have the binding... seems like I missunderstud something there, sorry. I placed the annotation in the class representing the remote interface for the bean, that did not work. I now placed the annotation in the bean and so get the binding I want in the JNDI Tree.

                    Thx
                    Marc

                    • 7. Re: EJB 3.0, JBoss 4.0.4.RC2 JNDI Binding
                      marcreis

                      hmm, next problem...
                      I would greatly appreciate a tip, link, hint or example for an efficient way of doing the JNDI lookup on the 4.0.4.RC2 and EJB 3.0 RC 6, like the "old" style of just asking for the name of the interface and looking this up

                      The problem that I have is, that I don?t wish to hard code each interface name, I am looking for a ?dynamic? approach, like before.
                      Since I only want the client to know the interface, I can?t fetch the value of the ?@RemoteBinding? ? Annotation of the bean, (and that?s the only place where it has effects on the naming in the JNDI Tree).

                      Also, I would still not be able to set it dynamic since you cant do something like ?@RemoteBinding = (jndiBinding = de.home.test.interfaces.INatPersLstRemote.class.getName())?or similar (as far as I have read up till now).

                      So how do most of you handle this?
                      I tried to find some documentation or examples on this ?new? naming approach, but have not really found anything (just lots of ?older ? examples, where in most cases they just used the name as a constant like ?myBean/remote?).

                      Thx ahead !