Getting local interface from java:comp/env. Big Problems

Discussion in 'Java' started by Anonymous, Oct 21, 2004.

  1. Anonymous

    Anonymous Guest

    Hi, im using Websphere studio application developer.

    I have an EJB bean HelloWorldEntity (from the websphere j2ee hello
    world tutorial) with an interface ive made called
    HelloWorldEntityLocalHome.

    In the application client descriptor editor I selected references (for
    HelloWorldEntity)
    added a Local reference, ejb/HelloWorldEntityLocal
    in the Websphere Bindings section of the references page I put in
    JNDI name: ejb/helloworld/ejb/HelloWorldEntityLocalHome
    the source looks like this.
    <ejb-local-ref id="EJBLocalRef_1098353324662">
    <ejb-ref-name>ejb/HelloWorldEntityLocal</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>helloworld.ejb.HelloWorldEntityLocalHome</local-home>
    <local>helloworld.ejb.HelloWorldEntityLocal</local>
    <ejb-link>HelloWorldEntity</ejb-link>
    </ejb-local-ref>

    Then I delete any servers and right click HelloWorldEJB project and
    click run on server, generating deployment code, creating a new server
    and creating tables and data sources.

    Then I try this code from the application client...
    System.out.println("Performing the lookup..");
    InitialContext initContext = new
    InitialContext();
    HelloWorldEntityLocalHome helloWorldEntityLocalHome =
    (HelloWorldEntityLocalHome)initContext.lookup("java:comp/env/ejb/HelloWorldEntityLocal");
    HelloWorldEntityLocal helloWorldEntityLocal =
    helloWorldEntityLocalHome.create(3);
    System.out.println("lookup successful.");


    I get javax.naming.NameNotFoundException: Name
    "comp/env/ejb/HelloWorldEntityLocal" not found in context "java:".

    The only thing found to be successful is putting a ejbref remote
    reference in the application client descriptor and accessing the
    remote beans.
    But the remote beans dont have the relationship related methods I need
    for my other, much larger and more complex project that has multiple
    entitys & relationships. Note that you can not add ejb local
    references to the client deployment descriptor.

    Anyone know how to fix this so I can get the local home interface? ive
    tried absolutely everything and any help would be appreciated.

    Thanks in advance,
    Robbie Cahill
    (a very frustrated programmer).








    Here is my full application client code.

    public class HelloWorldEJBTestClient {

    public static void main(String[] args) {

    String firstNameParam = "John";
    String lastNameParam = "Smith";
    int id = 100;

    // Perform the lookup
    HelloWorldEntityHome helloEntityHome = null;
    try {
    System.out.println("Performing the lookup..");
    InitialContext initContext = new
    InitialContext();
    HelloWorldEntityLocalHome helloWorldEntityLocalHome =
    (HelloWorldEntityLocalHome)
    initContext.lookup("java:comp/env/ejb/HelloWorldEntityLocal");
    HelloWorldEntityLocal helloWorldEntityLocal =
    helloWorldEntityLocalHome.create(3);
    System.out.println("lookup successful.");
    } catch (javax.naming.NamingException e) {
    System.out.println("Whoops! Error retrieving the home interface: "
    + e);
    e.printStackTrace();
    System.exit(0);
    } catch (Exception e) {

    System.out.println(e);
    }
    }
    }
     
    Anonymous, Oct 21, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page