• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data not returned from Session bean

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a stateless session bean to query data from the database. The method on server executes properly but I am not getting data displayed in JSP. Method getQuestion executes fine on server but System.out.println (very next line) of JSP is never executed. Can anyone suggest? The sample code is :
<%
J2eeQuiz quiz = null;
try {
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("java:comp/env/neha/quiz/TheQuiz");
J2eeQuizHome home = (J2eeQuizHome)PortableRemoteObject.narrow(
objRef, J2eeQuizHome.class);
quiz = home.create();
} catch (RemoteException ex) {
System.out.println("Couldn't create quiz bean."+ ex.getMessage());
} catch (CreateException ex) {
System.out.println("Couldn't create quiz bean."+ ex.getMessage());
} catch (NamingException ex) {
System.out.println("Unable to lookup home: "+ "TheQuiz "+ ex.getMessage());
}
Question[] questions = quiz.getQuestions(5);
System.out.println("Testing"+(questions==null ? " NULL" : "LEN"));
session.setAttribute("quest", questions);
..
..
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any call to an EJB can throw an exception -- since you didn't wrap the call to getQuestions() in an exception handler, the default exception handler is getting called. Try putting the whole thing inside a try..catch block that catches "Exception" and see what kind of exception is being raised.
Kyle
 
reply
    Bookmark Topic Watch Topic
  • New Topic