<%@ 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" %>
<%
try {
// Get an InitialContext
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "http://localhost:7001");
Context ctx = new InitialContext(h);
TraderHome home = (TraderHome)ctx.lookup("statelessSession.TraderHome");
Trader trader = home.create();
String st = trader.getName();
out.print(st);
} catch (Exception e)
{
e.printStackTrace();
}
%>
-
Calling EJB from JSP (4 messages)
- Posted by: Chowdhary Meghana
- Posted on: July 29 2002 05:10 EDT
Threaded Messages (4)
- Calling EJB from JSP by Lasse Koskela on July 29 2002 05:36 EDT
- Calling EJB from JSP by Joe Mallings on July 29 2002 08:29 EDT
- Calling EJB from JSP by Brian Chan on July 29 2002 09:26 EDT
- Calling EJB from JSP by Chowdhary Meghana on July 30 2002 00:22 EDT
-
Calling EJB from JSP[ Go to top ]
- Posted by: Lasse Koskela
- Posted on: July 29 2002 05:36 EDT
- in response to Chowdhary Meghana
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); -
Calling EJB from JSP[ Go to top ]
- Posted by: Joe Mallings
- Posted on: July 29 2002 08:29 EDT
- in response to Chowdhary Meghana
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 :-
"statelessSession.TraderHome"
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 :-
"java:/comp/env/ejb/TraderHome"
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 ?
-
Calling EJB from JSP[ Go to top ]
- Posted by: Brian Chan
- Posted on: July 29 2002 09:26 EDT
- in response to Chowdhary Meghana
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.
...........
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
.............. -
Calling EJB from JSP[ Go to top ]
- Posted by: Chowdhary Meghana
- Posted on: July 30 2002 00:22 EDT
- in response to Brian Chan
Hello All,
Thanks a lot for ur valuable replies.
regards,
Rao.