<%@ page import="examples.ejb.basic.statelessSession.*" %>
<%@ page import="java.rmi.RemoteException" %>
<%@ page import="java.util.Properties" %>
<%@ page import="javax.ejb.CreateException" %>
<%@ page import="javax.ejb.RemoveException" %>
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="javax.rmi.PortableRemoteObject" %>
// Get an InitialContext
Properties h = new Properties();
Context ctx = new InitialContext(h);
TraderHome home = (TraderHome)ctx.lookup("statelessSession.TraderHome");
Trader trader = home.create();
String st = trader.getName();
} catch (Exception e)
Perhaps you should narrow the looked-up object to an interface extending EJBHome:
MyHome myHome = <lookup from JNDI>
myHome = (MyHome) PortableRemoteObject.narrow(myHome, MyHome.class);
It would actually help if you give details of the exception or error you are receiving rather than just pasting in your code fragment !!!
Some things to try, :-
1. Since you are using a Properties class for the arg to InitialContext, supply the SECURITY_PROVIDER and SECURITY_CREDENTIALS fields just in case you haven't got integrated logins to your weblogic server (i.e connections as guest)
2.Do you actually have a JNDI context setup as :-
or is this a package / class combinations ?
The name you put in here is the name you have defined in your ejb-jar.xml file which maps to you weblogic-ejb-jar.xml file. There should be a <jndi-name> in that file. Put that name in there. Also, if you are using 'ejb/BeanName' syntax you may want to quote as :-
again, it depends on how you have constructed your xml files !!!!
If its a JSP calling an EJB, I'm assuming you have setup the proper <ejb-ref> definition in your web.xml file ?
Your "Context.PROVIDER_URL" should have a value of t3://localhost:7001 instead of http://localhost:7001
Similarly you use "t3" in weblogic to lookup any JNDI Resources.
Thanks a lot for ur valuable replies.