• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

EJBContext error..

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
rajatn,
Thanks for joining JavaRanch, but could you take a quick look at the naming policy and edit your profile accordingly.
 
Rajat Nayer
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Chris, As you would see now, i have updated the display name.
Now, It would be helpful if I get some answers to my queries
 
Chris Mathews
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rajatn:
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>>


This error is being thrown from within your EJB, it is not a problem with your JSP page. It looks look you are calling a deprecated method from within your EJB, however I would need to see the code for your DemoBean class to provide further input.
 
Rajat Nayer
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah Chris, It turned out that the code i had copied from a tutorial was using getEnvironment() method which has since been deprecated.
Thanx for the help.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic