7 Replies Latest reply on Mar 11, 2003 9:27 AM by Saurav

    javax.naming.NameNotFoundException

    jag Newbie

      Hi,I have a problem when I wanna to do jsp+ejb.
      I wanna let these files work in JBoss-2.4.10_Tomcat-3.2.3
      but it is showing me a error
      message:"javax.naming.NameNotFoundException:ejb not bound"
      I have not idea aobut it.
      the jsp file is :
      <%@ page import="javax.naming.InitialContext,
      javax.rmi.PortableRemoteObject,
      java.io.PrintWriter,
      ejb.session.Hello,
      ejb.session.HelloHome"%>


      <%@page import
      = "javax.servlet.*,javax.servlet.http.*,java.io.*,javax.naming.*,javax.ejb.
      *,javax.rmi.PortableRemoteObject"%>

      <%!
      ejb.session.HelloHome helloHome = null;
      public void jspInit(){
      try{
      InitialContext ctx = new InitialContext();
      Object objref = ctx.lookup("java:comp/ejb/session/HelloHome");
      helloHome = (ejb.session.HelloHome)PortableRemoteObject.narrow
      (objref, ejb.session.HelloHome.class);
      }
      catch (Exception NamingException){
      NamingException.printStackTrace();
      }
      }
      %>
      <%
      try
      {
      Hello obj = helloHome.create();
      %>
      <% obj.sayHello();
      obj.sayHello();
      %>
      <%
      }
      catch (Exception CreateException)
      { CreateException.printStackTrace(); }

      %>



      and my ejb file is in the WEB-INF/classes/ejb/session
      my ejb-jsr.xml :
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
      JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
      <ejb-jar>
      <display-name>ejb</display-name>
      <enterprise-beans>

      <ejb-name>HelloEJB</ejb-name>
      ejb.session.HelloHome
      ejb.session.Hello
      <ejb-class>ejb.session.HelloBean</ejb-class>
      <session-type>Stateful</session-type>
      <transaction-type>Container</transaction-type>

      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>
      Transaction attributes for 'HelloEJB'
      methods

      <ejb-name>HelloEJB</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      I thing my programs should be right
      but I don't know what should I do in jboss to make the wrong get away.
      just "jboss.xml"??
      I don't think so.
      so,anyone could tell me the solution??
      thank all.

        • 1. Re: javax.naming.NameNotFoundException
          Joel Vogt Master

          include a jboss.xml that maps a jndi name to your ejb name. Then use this lookup and not the java:comp one as this will not work as you discovered

          • 2. Re: javax.naming.NameNotFoundException
            jag Newbie

            Thank you
            but,can you tell me the detail about it??
            what should I do in jboss.xml??
            can you give a a simple example of jboss.xml??
            thank a lot.

            • 3. Re: javax.naming.NameNotFoundException
              Joel Vogt Master

              yep, from your example something like

              <?xml version="1.0" encoding="Cp1252"?>

              false
              <enterprise-beans>

              <ejb-name>HelloEJB</ejb-name>
              <jndi-name>ejb/session/HelloHome</jndi-name>

              </enterprise-beans>



              Then try your lookup with 'ejb/session/HelloHome'.

              jboss.xml goes with your ejb-jar.xml. There are lots more details in the jboss docs about this.

              • 4. Re: javax.naming.NameNotFoundException
                jag Newbie

                still the same error-_-
                my ejb-jar.xml is :
                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
                <ejb-jar>
                <display-name>ejb</display-name>
                <enterprise-beans>

                <ejb-name>HelloEJB</ejb-name>
                ejb.session.HelloHome
                ejb.session.Hello
                <ejb-class>ejb.session.HelloBean</ejb-class>
                <session-type>Stateful</session-type>
                <transaction-type>Container</transaction-type>


                <ejb-name>InterestEJB</ejb-name>
                ejb.session.InterestHome
                ejb.session.Interest
                <ejb-class>ejb.session.InterestBean</ejb-class>
                <session-type>Stateless</session-type>
                <transaction-type>Bean</transaction-type>

                </enterprise-beans>
                <assembly-descriptor>
                <container-transaction>
                Transaction attributes for 'HelloEJB' methods

                <ejb-name>HelloEJB</ejb-name>
                <method-name>*</method-name>

                <trans-attribute>Required</trans-attribute>
                </container-transaction>
                </assembly-descriptor>
                </ejb-jar>

                and the ejb-jar.xml and jboss.xml are in /WEB-INF/

                • 5. Re: javax.naming.NameNotFoundException
                  jag Newbie

                  should I send my "ejbdemo" to you?
                  you may give your hand to me to find the solution about my "ejbdemo" if you have time.

                  • 6. Re: javax.naming.NameNotFoundException
                    Mu Ah Newbie

                    I'm experiencing the same problem. I've defined my ejb-jar and jboss.xml but it gives me the 'Not Bound' message. Did you find any solution to this?

                    • 7. Re: javax.naming.NameNotFoundException
                      Saurav Newbie

                      Hi,

                      Me too got stucked up here ! Please tell me how to get rid of this 'not bound' headache. I am using JBoss 3.0.6, JDK 1.4.I have went through the ejb-jar.xml and jboss.xml and referred the JBoss documents too.

                      Any clue ?

                      Thanking you in anticipation.