• 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

Class cast exception

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using JRun 3.0 and using servlets and jsp's. The JSP's are however behaving in an unpredictable manner and throwing classcast exception every now and then. At times it works and at times it throws this error. Could somebody help out??
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do these exceptions always happen at the same place in the code? Could you copy a few exception prints/stack traces here so we can see a bit mre about the error.
Thanks.
 
Sujith Nair
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Iam now writing the error it generates on the browser
java.lang.ClassCastException
at jrun____ScipDev____jsp____SeraNews____Quiz12ejsp23._jspService(jrun____ScipDev____jsp____SeraNews____Quiz12ejsp23.java, Compiled Code)
at allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java, Compiled Code)
at allaire.jrun.jsp.JSPServlet.service(JSPServlet.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java, Compiled Code)
at QuizServlet.service(QuizServlet.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java, Compiled Code)
at allaire.jrun.servlet.Invoker.service(Invoker.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java, Compiled Code)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java, Compiled Code)
at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java, Compiled Code)
at allaire.jrun.ThreadPool.run(ThreadPool.java, Compiled Code)
at allaire.jrun.WorkerThread.run(WorkerThread.java, Compiled Code)
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't worked with JRun, only with Java Web Server. However, I ran into the same problem, and needed to do two things: 1. Originally, I had put my JSPs in a package, and I had to take them out of the package. 2. I had to move the Java classes (servlets) from the servlets folder to the classes folder. Hope this helps.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ClassCastException will occur due to runtime casting errors. It occurs when we try to cast an object to a class type which is incombatible. You may have to check your code once more I think.
regds
maha anna
I just give you an example:


[This message has been edited by maha anna (edited December 04, 2000).]
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using weblogic I ran into class cast exception. It was because the servlet class loader were loading the class. Here is a link to what weblogic has to say about this. It may help, I dont know...worth a try http://www.weblogic.com/docs45/classdocs/API_servlet.html#classcastexception
best of luck paul
 
Sujith Nair
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Thanks a lot. Yeah it definitely is a classloader issue. We have got the work around by putting the beans in the JRun's classpath. I just looked at the documentation at weblogic. They definitely have done a good job. Their explanation I believe will be valid for most of the Application servers available.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
There is a simple solution for this. Try using scope="page" (instead of scope="session") in your <jsp:UseBean> Tag.
This will make sure that the class is loaded for every page instead of once every session.
If the scope is session, the servlet class loader will load the class only once per session. So the object in the later page will be casted to the class of the previous session which is incompatable (unlike the object in the previous page).
Please let me know if my statement is incorrect.
------------------
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic