ejb local references

Discussions

EJB programming & troubleshooting: ejb local references

  1. ejb local references (1 messages)

    Can anyone tell me why the following code generates an Exception? The code is in a stateless session bean named SB1 that is trying to obtain a local ref to another stateless session bean named SB2. SB2 is deployed and appears in my jndi tree as "SB2" and "SB2Local".

    Code:

          context = getInitialContext();
          SB2LocalHome sb2Home = (SB2LocalHome) context.lookup("java:comp/env/ejb/SB2Local");

    Exception:

    javax.ejb.CreateException: Create Exception in SB1: Unable to resolve 'app/ejb/SB1.jar#SB1/comp/env/ejb/SB2Local' Resolved: 'app/ejb/SB1.jar#SB1/comp/env' Unresolved:'ejb'
  2. ejb local references[ Go to top ]

    Can anyone tell me why the following code generates an Exception? The code is in a stateless session bean named SB1 that is trying to obtain a local ref to another stateless session bean named SB2. SB2 is deployed and appears in my jndi tree as "SB2" and "SB2Local".

    >
    > Code:
    >
    >       context = getInitialContext();
    >       SB2LocalHome sb2Home = (SB2LocalHome) context.lookup("java:comp/env/ejb/SB2Local");
    >
    > Exception:
    >
    > javax.ejb.CreateException: Create Exception in SB1: Unable to resolve 'app/ejb/SB1.jar#SB1/comp/env/ejb/SB2Local' Resolved: 'app/ejb/SB1.jar#SB1/comp/env' Unresolved:'ejb'

    Do you have an ejb-ref or ejb-local-ref referencing SB2 in the deployment descriptor for SB1.

    If not, you probably shouldn't use java:comp/env since it just looks at the references you have declared. I would suggest adding an ejb-ref and/or ejb-local-ref (looking at your code, you probably want ejb-local-ref) and see if that clears things up. Or you can just use the "real" JNDI name in your lookup.