5 Replies Latest reply on Sep 9, 2006 7:08 AM by Christian Bauer

    A solution for naming and finding resources within J2EE?

    None None Master

      What is the best solution for naming and locating resources within J2EE? Is there going to be a replacement for JNDI? I have been working on this for about a week, and I can't get my JSF backing bean to find a simple stateless session bean in my EJBs. At this point, I'm wondering, is JNDI the right tool for this job? It seems like a simple idea: JNDI maintains a directory-like structure, and I can find things in it, but it seems like it has a few problems:

      a) There's never anything in it

      b) There's no way to list all the resources available within an InitialContext. If I could just make it dump out what it has in it, I might be able to find out if things are being put in wrong. Are there any debugging tools for this? Or should I somehow recmopile my own JNDI with logging or something in it?

      At this point I'm starting to wonder how / if JNDI is actually used in real systems. It does not seem like it should be that hard.

        • 1. Re: A solution for naming and finding resources within J2EE?
          jaikiran pai Master

           

          I have been working on this for about a week, and I can't get my JSF backing bean to find a simple stateless session bean in my EJBs. At this point, I'm wondering, is JNDI the right tool for this job?


          One of the common mistakes that happen is that while deploying the bean you bind the bean to some jndi name and later try looking up the bean with some other jndiname. This ofcourse is not intentional, but because of some mistake in writing the deployment descriptors in your application.

          If I could just make it dump out what it has in it, I might be able to find out if things are being put in wrong


          You can use the jmx-console for this. Access the following url:

          http://localhost:8080/jmx-console

          On the jmx-console web page, you will see a lot of services listed. One of them will be service=JNDIView . Click on the same. You will see a page which will show the methods and attributes of this jndi service. Click on the Invoke button, next to the list operation. You will see a dump of the objects that are bound to the jndi

          Try it out and let us know of any issues.


          • 2. Re: A solution for naming and finding resources within J2EE?
            None None Master

            THANK YOU! That gave me a dump of every bean in JNDI and let me find exactly what I'm looking for. Ok, it is as simple as it should be.

            Now I have one more question which should be even easier:

            Is it possible to use the @EJB annotation to inject a stateless session bean from my EJBs into my JSF backing bean? I assume that all I need to do is have the backing bean member be of the right class, and use @EJB, and that's it, right? I tried that and it doesn't work, and I looked around on Google and it sounds like that may not be supported yet, as a limitation within Tomcat. Is this true?

            • 3. Re: A solution for naming and finding resources within J2EE?
              None None Master

              As another way of stating it: If I can grab it from an InitialContext I should be able to have it injected with @EJB, right? Because that isn't working. How does the @EJB decide which bean to grab? I assume it looks at the class name, so if I have:

              @EJB private myBean;

              it will look in JNDI for "MyAppName/myBean/local", right? Because that's in the context but it isn't injecting.

              • 4. Re: A solution for naming and finding resources within J2EE?
                jaikiran pai Master

                Frankly speaking, i havent worked with EJB3. You might post your ejb-jar.xml and jboss.xml(the relevant portions), so that someone out here might be able to help you out.

                • 5. Re: A solution for naming and finding resources within J2EE?
                  Christian Bauer Master

                  In case anybody finds this thread: Yes, @EJB injection in JSF backing beans is not supported right now by Tomcat. This is somewhat obscure if you only look at JSF, but also a limitation for JSPs or Servlets. Explained here: http://docs.jboss.org/ejb3/app-server/tutorial/ear/ear.html

                  Seam helps, it can bind JSF UI components directly to EJBs without any backing beans.