I am trying to access a bean from a
JSP and have the foll code piece:
..............
String url = "t3://localhost:7001";
public Context getInitialContext() throws Exception {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
//p.put(Context.PROVIDER_URL, url);
return new InitialContext(p);
}
String getStackTraceAsString(Exception e)
{
// Dump the stack trace to a buffered stream, then send it's contents
// to the JSPWriter.
ByteArrayOutputStream ostr = new ByteArrayOutputStream();
e.printStackTrace(new PrintWriter(ostr));
return(ostr.toString());
}
%>
<%
String op="";
try {
// Contact the AccountBean container (the "AccountHome") through JNDI.
Context ctx = getInitialContext();
out.println("initial context got !!");
DemoHome home = (DemoHome) ctx.lookup("demo.DemoHome");
out.println("home got !!");
%>
<p>
<%
Demo ac = null;
try {
ac = (Demo) home.create();
out.println("create called!!");
if (ac==null)
out.println("ac is null!");
}
catch (Exception ee) {
out.print("exception 1");
}
%>
<p>
<%
try {
out.println("going to call method!");
if (ac!= null)
op = ac.demoSelect();
else
out.println("ac is null->error!!");
out.println(ac.demoSelect());
out.println("string got!!");
out.println(op);
}
catch (Exception e) {
getStackTraceAsString(e);
e.printStackTrace();
out.println("error 2");
}
}
catch(Exception e)
{
out.println("error 3!");
}
..................
It gives an error on trying to access the method "demoSelect".
e.printStackTrace gives the output:
-------------------
java.lang.RuntimeException: javax.ejb.EJBContext.getEnvironment is deprecated in
EJB 1.1. EJB 1.1 compli
ant containers are not required to implement this method. Use
java:comp/env instead.
<<no stack trace available>>
--------------------
What is wrong???
pls help
-R