8 Replies Latest reply on Sep 18, 2002 2:14 AM by Mark McCurry

    JNDI problem - i think?

    Pamela Smith Newbie

      The jboss-3.0.0_tomcat-4.0.3 server is running well. I can access http://localhost:8082. I can also access my html http://localhost:8080/BonusRoot/bonus.html.

      bonus.html is a form with a button when clicked directs the request to a Servlet.

      The servlet calls a session bean. The session bean executes a simple calculation, and returns the result to the servlet. The servlet returns the result to the client in html format.

      My problem: is a jndi problem (i think). The servlet cannot find the session bean. The servlet returns a properly formatted html response but without the session beans calculations.

      Question 1) Aside from the ear file (which includes both the war and the bean jar file), do i need to include anything else?
      Many thanks for your help.

        • 1. Re: JNDI problem - i think?
          Joel Vogt Master

          Well, depends on what is in the war, ear and jar file.
          When you say your servlet cannot find the session bean, is this throwing an error in your server log?

          It might be useful to post this first so hopefully we can easily fix the problem

          • 2. Re: JNDI problem - i think?
            Pamela Smith Newbie

            Here is the error:

            ERROR [STDERR] javax.naming.NameNotFoundException: calcs not bound
            ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)

            ...
            ERROR [STDERR] at org.jnp.server.NamingServer.getBinding...
            ERROR [STDERR] at org.jnp.server.NamingServer.getObject...
            ERROR [STDERR] at org.jnp.server.NamingServer.lookup...
            ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup...
            ERROR [STDERR] at javax.naming.InitialContext.lookup...

            ERROR [STDERR] at BonusServlet.init(BonusServlet.java:16) ...

            /*************************************************/
            Here is part of the servlet code: including line 16

            import javax.servlet.*;
            import javax.servlet.http.*;
            import java.io.*;
            import javax.naming.*;
            import javax.rmi.PortableRemoteObject;
            import Beans.*;

            public class BonusServlet extends HttpServlet {
            CalcHome homecalc;

            public void init(ServletConfig config) throws ServletException{

            //Look up home interface
            try {
            InitialContext ctx = new InitialContext();
            Object objref = ctx.lookup("calcs");
            homecalc = (CalcHome)PortableRemoteObject.narrow(objref, CalcHome.class);
            } catch (Exception NamingException) {
            NamingException.printStackTrace();
            }
            }
            /***********************************************/
            The code is taken from the SUN tutorial by Monica Pawlan and it works perfectly on the app server and deployment tool that comes with the j2sdkee1.3 download.

            Many thanks in advance for your help.

            • 3. Re: JNDI problem - i think?
              Joel Vogt Master

              Just make sure to check what jndi name is being used in your session bean configuration. (you xml files).
              Also, on deploy of your app does it say that the session bean is deployed correctly? It should also tell you what jndi name it was bound to.

              • 4. Re: JNDI problem - i think?
                Pamela Smith Newbie

                Thanks for responding.

                The jndi name is: calcs.
                It says the jndi name is not bound.

                This is strange since I am merely copying (i.e. copy-paste the ear file) w/c works perfectly on the j2sdkee1.3 built-in server.I re-compiled the tutorial and re-deployed. It works on the built-in sun server but not on JBoss. Same problem ...

                I am referring to the tutorial (an excellent one) found here:
                http://developer.java.sun.com/developer/onlineTraining/J2EE/Intro/

                • 5. Re: JNDI problem - i think?
                  Joel Vogt Master

                  can you post a bit of your config? Probably the relevant parts of jboss.xml would be good to start

                  • 6. Re: JNDI problem - i think?
                    Mark McCurry Newbie

                    First, I want to thank Pamela for pointing out Monica Pawlan's tutorial. It is a great place to start for those of us who are new to J2EE.

                    Second, I have lesson 1 (L1) working properly under JBoss 3.0.3RC1 (Jetty) if anyone is still interested. I have a small ZIP containing everything needed. There is a DOS BATch file that steps through the process without using the J2EE SDK (sorry, Linux box is down right now... hardware problem... loose nut behind the programmer's keyboard).

                    Joel, you hit the nail right on the head. The tutorial uses Sun's DeployTool to automagically create the EAR. While it thoughtfully includes an xml specific to Sun's little j2ee app server... it fails to provide the required jboss.xml! :)

                    Finally, If anyone using 3.0.x (Jetty) is having trouble with the sample 'template', I want to point out Bill's excellent walk through at http://sammaher.com/jboss/

                    Thanks to all the JBoss dudes for creating such an excellent product.

                    /mark

                    • 7. Re: JNDI problem - i think?
                      Mark McCurry Newbie

                      Huh... I wrote up a great post, and it seems to have gotten lost!

                      Well, the short version is, I have Monica Pawlan's tutorials working under JBoss 3.0.3RC1 (Jetty) if anyone is interested.

                      Joel nailed it. The tutorial uses Sun's DeployTool to automagically create the EAR. While it does provide some xml specific to Sun's little j2ee server... it fails to provide the required jboss.xml! :)

                      I have a ZIP containing the required files and a step by step if anyone wants it.

                      mark

                      • 8. Re: JNDI problem - i think?
                        Mark McCurry Newbie

                        Pamela,
                        I've tried twice now to post to this thread, but it keeps getting lost.
                        Anyway, I have Monica Pawlan's tutorials (well, lesson 1 anyway) running fine under JBoss 3.0.3RC1 (Jetty) on Windows. I have a little ZIP with the required files and a little step by step if you are still interested.

                        Mark