2 Replies Latest reply on Jul 10, 2003 5:06 PM by jgkenned

    Problem with JNDI

    chemapo Newbie


      I'm trying to deploy my first web application and I have the next problem:

      My directories (D) in the deploy directory are:

      -- cart_session.war (D)
      -- WEB-INF (D)
      -- jboss-web.xml
      -- web.xml
      -- classes(D)
      -- cart_session(D)
      -- Cart
      -- CartBean
      -- CartHome
      -- Item

      My ejb is a stateful session bean and i'm trying to access it directly from a jsp (index.jsp)

      I have declared an ejb external reference as in

      my Jboss-web.xml file:

      <!DOCTYPE jboss-web
      PUBLIC "-//JBoss//DTD Web Application 2.3//EN"

      my web.xml file:

      <!DOCTYPE web-app PUBLIC
      "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"




      My index.jsp file is:

      <%@ page

      try {
      Context lContext = new InitialContext();
      Object ref=lContext.lookup("java:comp/env/ejb/cart_session/Cart");

      catch( Exception e ) {
      out.println( "Caugth exception: " + e.getMessage() );

      During deployment process, jboss informs that cart_session.war has been deployed succesfully but when i browse index.jsp it can locate my ejb jndi_name, i have also tried to find my ejb jndi name using jmx-console jndiview-->list and i couldn't find it.

      Could you help me please

        • 1. Re: Problem with JNDI
          Vishal Sharma Expert

          If yr application is in the same JVM then you don't need descriptors for EJB in web.xml file.

          Read this thread, i have just read that.
          http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t= will explain few things for you.

          • 2. Re: Problem with JNDI
            jgkenned Newbie

            Hi chemapo,

            Not sure where to begin here. Well, for starters, EJB's are deployed in JAR files not WAR files. There is a strict format of how that JAR file is laid out. This standard is defined by Sun. Your Cart, CartBean and CartHome classes will all be part of the JAR file along with some XML deployment descriptors. WAR files will contain things like servlets, jsp, property files, web.xml, jboss-web.xml, html, graphics and more. JBOSS will deploy WAR files to the web container and JAR files containing EJB's to its EJB container.

            Looks like you are working with the cart example that comes with the j2ee reference implementation. I did that and will upload it for your review.