java:comp/env in WAS/WebSphere Application Developer

Discussions

EJB programming & troubleshooting: java:comp/env in WAS/WebSphere Application Developer

  1. Hi folks!

    Does one need to do anything special to gain access/setup "java:comp/env" when using WAS 5.0 that comes with WebSphere Application Developer?

    Basically, I have two Session beans, both of which have only local interfaces and I'm trying to call one bean from the other but no matter what I do, I get a naming exception:

    javax.ejb.EJBException: nested exception is: javax.naming.NameNotFoundException: Name comp/env/ejb not found in context "java:".

    This is how I'm trying to lookup the bean:

    InitialContext jndiCtx = new InitialContext();
    MyEjbLocalHome ejbLocalHome = (MyEjbLocalHome)jndiCtx.lookup("java:comp/env/ejb/MyEjbLocalHome");
    // It never makes it past this point


    Any help is greately appreciated.


    PS: Sorry if the message isn't properly formatted, it's my first post and there appears to be no "Preview" button...

    Threaded Messages (2)

  2. reply[ Go to top ]

    Sergei,

    Do you have a bean reference provided in a deployment descriptor for the bean you're trying to use?

    Alex
  3. reply[ Go to top ]

    Do you have a bean reference provided in a deployment descriptor for the bean you're trying to use?


    That's what the problem was. Thank you, Alex!
    I did define references for all beans but I had a slight misunderstanding of how they work. I thought that I needed to define only one reference per bean and that reference would point to the bean itself. I guess I was thinking that doing this would make these beans accessible to all other beans via "java:comp/env". Well, obviously this is wrong.