0 Replies Latest reply on Dec 26, 2002 1:51 PM by Bill Goss

    not bound exception - it seems to be a favorite

    Bill Goss Newbie

      I'm embarrassed to ask to board for help but I'm getting very frustrated with a ejb not bound exception when attempting to use a local lookup from a servlet. Following are the pertinent file information:

      jboss 3.0.4 w/tomcat, win2000k.

      ejb-jar.xml snippet:

      <display-name>User</display-name>
      <ejb-name>User</ejb-name>
      <ejb-class>com.kaiser.pas.user.UserBean</ejb-class>
      <session-type>Stateless</session-type>
      <ejb-ref>
      <ejb-ref-name>ejb/User</ejb-ref-name>
      com.kaiser.pas.user.UserHome
      com.kaiser.pas.user.UserRemote
      <ejb-ref-type>Session</ejb-ref-type>
      <ejb-link>User</ejb-link>
      </ejb-ref>
      <ejb-local-ref>
      <ejb-ref-name>ejb/local/User</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>com.kaiser.pas.user.UserLocalHome</local-home>
      com.kaiser.pas.user.UserLocal
      <ejb-link>User</ejb-link>
      </ejb-local-ref>
      <transaction-type>Bean</transaction-type>
      <resource-ref>
      <res-ref-name>jdbc/DB2DS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Application</res-auth>
      </resource-ref>



      jboss.xml snippet:

      <ejb-name>User</ejb-name>
      <resource-ref>
      <res-ref-name>jdbc/DB2DS</res-ref-name>
      <resource-name>DataSourceRef</resource-name>
      <jndi-name>java:/DB2DS</jndi-name>
      </resource-ref>



      web.xml snippet:
      <ejb-ref>
      <ejb-ref-name>ejb/User</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      com.kaiser.pas.user.beans.UserHome
      com.kaiser.pas.user.beans.UserRemote
      <ejb-link>User</ejb-link>
      </ejb-ref>

      and
      <ejb-local-ref>
      <ejb-ref-name>ejb/local/User</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>com.kaiser.pas.user.beans.UserLocalHome</local-home>
      com.kaiser.pas.user.beans.UserLocal
      <ejb-link>User</ejb-link>
      </ejb-local-ref>


      From JNDIView (which seems to me indicates the ejb's are bound to local/<ejb-name>):
      java:comp namespace of the Program bean:
      +- UserTransaction (class: javax.transaction.UserTransaction)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- jdbc (class: org.jnp.interfaces.NamingContext)
      | | +- DB2DS[link -> java:/DB2DS] (class: javax.naming.LinkRef)
      | +- ejb (class: org.jnp.interfaces.NamingContext)
      | | +- Program[link -> Program] (class: javax.naming.LinkRef)
      | | +- local (class: org.jnp.interfaces.NamingContext)
      | | | +- Program[link -> local/Program] (class: javax.naming.LinkRef)

      java:comp namespace of the Member bean:
      +- UserTransaction (class: javax.transaction.UserTransaction)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- jdbc (class: org.jnp.interfaces.NamingContext)
      | | +- DB2DS[link -> java:/DB2DS] (class: javax.naming.LinkRef)
      | +- ejb (class: org.jnp.interfaces.NamingContext)
      | | +- local (class: org.jnp.interfaces.NamingContext)
      | | | +- Member[link -> local/Member] (class: javax.naming.LinkRef)
      | | +- Member[link -> Member] (class: javax.naming.LinkRef)

      java:comp namespace of the User bean:
      +- UserTransaction (class: javax.transaction.UserTransaction)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- jdbc (class: org.jnp.interfaces.NamingContext)
      | | +- DB2DS[link -> java:/DB2DS] (class: javax.naming.LinkRef)
      | +- ejb (class: org.jnp.interfaces.NamingContext)
      | | +- local (class: org.jnp.interfaces.NamingContext)
      | | | +- User[link -> local/User] (class: javax.naming.LinkRef)
      | | +- User[link -> User] (class: javax.naming.LinkRef)


      call from servlet:
      Properties ejbENV=System.getProperties();
      ejbENV.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      ejbENV.setProperty("java.naming.provider.url", "localhost:1099");
      ejbENV.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      System.setProperties(ejbENV);

      try
      {
      ctx=new InitialContext(ejbENV);

      userHome=(UserLocalHome) ctx.lookup("java:comp/env/local/User");
      userLocal=userHome.create();
      programHome=(ProgramLocalHome) ctx.lookup("java:comp/env/local/Program");
      programLocal=programHome.create();
      destinationHome=(DestinationLocalHome) ctx.lookup("java:comp/env/local/Destination");
      destinationLocal=destinationHome.create();
      }
      catch (Exception e)
      {
      System.out.println("ValidateLoginServlet: Can't connect to EJB's! Exception message="+e.getMessage());
      request.setAttribute("errormsg", "Can't connect to resources");
      transferControl("/index.jsp", request, response);
      return;
      }

      I have also tried:
      userHome=(UserLocalHome) ctx.lookup("java:comp/env/ejb/local/User");

      and other combinations (including using JNDI) to no avail. Every combination fails with a (as in the case above)
      11:58:34,004 INFO [STDOUT] ValidateLoginServlet: Can't connect to EJB's! Exception message=local not bound

      As I stated above, I'm a bit embarrassed to bring this here but am stymied and hope someone can point out my mistake.

      Thanks in advance

      Bill Goss

      Please let me know if you require any additional information.