Friday, January 08, 2010

How to get the JNDI of EJB in WebLogic 10g R3

If you want to the EJB accessible from general classes instead of managed beans, you have to let it can be searchable in JNDI tree. But you can not get the JNDI if you didn't set the mappedName in WebLogic 10g R3.

A sample:

@Stateless ( name="UserBean", mappedName="ejb.User")
public class UserBean implements UserLocal, UserRemote {
}


After you deployed it in Webglogic 10, you can get access to the remote interface with:

String JNDI_NAME = "ejb.User#" + UserRemote.class.getName();
UserRemote user = (UserRemote) new InitialContext().lookup(JNDI_NAME);

No comments: