Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

EJB JNDI Exception

  • 06-01-2003 2:59pm
    #1
    Registered Users, Registered Users 2 Posts: 6,265 ✭✭✭


    Hi,

    I'm new to EJB and am currently writing my first bean, using the Sun Reference Implementation J2EE Server and deployment tool. I'm using examples provided in chapter 2 of the Wrox book "Professional EJB" to get me started.

    I have successfully written, compiled and deployed the application on the server, and now wish to test it using the example Java Client in the book. My Bean name is Salary, and is registered in the JNDI Server as Salary too, to keep things simple.

    The client code is as follows:

    try {
    InitialContext ctx = new InitialContext();
    Object objRef = ctx.lookup("Salary");

    SalaryHome home = (SalaryHome
    javax.rmi.PortableRemoteObject.narrow(
    objRef, SalaryHome.class);

    Salary bean = home.create();

    System.out.println("Monthly net salary: " +
    bean.calculateSalary(28000, 2, 500));

    } catch (javax.naming.NamingException ne) {
    System.out.println("Naming Exception caught: " + ne);
    } catch (javax.ejb.CreateException ce) {
    System.out.println("Create Exception caught: " + ce);
    } catch (java.rmi.RemoteException re) {
    System.out.println("Remote Exception caught: " + re);
    }

    When I attempt to run my client (which is one the same machine as the J2ee server) I get the following JNDI error:

    C:\ProEJB\Chapter2\code>java SalaryClient
    Naming Exception caught: javax.naming.NameNotFoundException: Salary not found

    Since I have copied the example code exactly, I can only assume it's a problem with my JNDI Server configuration. Can anyone help????


Comments

  • Registered Users, Registered Users 2 Posts: 2,029 ✭✭✭lynchie


    AFAIK, If your using the sun J2EE Server, all beans are bound to the following context within the JNDI tree java:comp/env/ejb/

    Thus your code should be
    Object objRef = ctx.lookup("java:comp/env/ejb/Salary");

    Check out
    the J2EE Tutorial for more info.


Advertisement