1 Reply Latest reply on Jun 5, 2003 5:35 PM by adrian.brock

    JNDI problems

    kipknots

      Hey, I'm working on my first EJB-application right now, but I'm having some problems with the jndi binding. When I try to create an interface, I'm getting the following error:
      org.apache.jasper.JasperException: ejb not bound
      with a stacktrace.

      I'm using the following code to try to connect to the remote interface of the bean:

      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      props.put
      (Context.PROVIDER_URL, "localhost:1099");

      Context ctx = new InitialContext(props);
      StudentControllerHome home =
      (StudentControllerHome)ctx.lookup
      ("StudentController");
      StudentController bean = home.create();

      This is the jboss.xml file that I use:

      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN"
      "http://www.jboss.org/j2ee/dtd/jboss.dtd">

      <enterprise-beans>

      <ejb-name>StudentEJB</ejb-name>
      <jndi-name>ejb/Student</jndi-name>


      <ejb-name>StudentControllerEJB</ejb-
      name>
      <jndi-name>StudentController</jndi-name>

      </enterprise-beans>




      and this is the web.xml file that I use:

      <?xml version="1.0" encoding="ISO-8859-1"?>

      <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

      <web-app>
      <display-name>web</display-name>
      <ejb-ref>
      <ejb-ref-name>StudentController</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      nl.hen.hio.j2ee_prototype.StudentControllerHome
      nl.hen.hio.j2ee_prototype.StudentController
      <ejb-link>StudentControllerEJB</ejb-link>
      </ejb-ref>


      </web-app>

      can anyone help me?
      cheers

        • 1. Re: JNDI problems

          Are your running Tomcat in a different JVM?

          You should be using new InitialContext()
          inside the app-server.

          You properties are incomplete.

          java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
          java.naming.provider.url=localhost


          Regards,
          Adrian