• Post Reply Bookmark Topic Watch Topic
  • New Topic

Data not returned from Session bean

 
Neha Haq
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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);
..
..
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!