• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.ClassCastException  RSS feed

 
Tirthankar Dutta Chaudhuri
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am getting java.lang.ClassCastException .
IN the follwing line . in a jsp page .
ResultBean rb=(ResultBean)request.getAttribute("resultdata");

IN the servlet code
ResultBean rb= new ResultBean();
rb.setaName(Acc.getName());
rb.setaIATA(Acc.getIATA());
request.setAttribute("resultdata", rb);
The Exception :

java.lang.ClassCastException
at jsp_servlet.__results._jspService(__results.java:131)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
l.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
l.java:305)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispat
herImpl.java:594)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispat
herImpl.java:409)
at CntlrServlet.doGet(CntlrServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
l.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
l.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
.run(WebAppServletContext.java:6310)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
Subject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
18)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
vletContext.java:3622)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
l.java:2569)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)


Thanks,
Tirthankar
 
Saket Barve
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tirthankar,

I doubt that the attribute is not being set for some reason. Why don't you add logs in your servlet to see if the attribute is really getting set? Additionally, you can test for null before doing the cast in your JSP.

Give us an update,
Saket
 
Tien-Chih Wang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check __results.java line 131 to see if any Class Cast error.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!