Thanks Scott,
That makes sense. I'll be looking forward to a release with this one fixed! :)
thanks again,
Matt Goss

Scott Stirling wrote:

The bean won't get reloaded when you reload the JSP.  I suspect you're making
changes to the bean or to the JSP, or both, and when you try to load a second
instance of the bean into memory, you get a cast exception.  Naturally, if you
restart JRun, the classloaders all get dumped and you start over clean.

Servlets and JSPs have different classloaders in JRun:

JRun relies on the system classloader for  everything in the system classpath.

For servlets, there is one class loader per web application.  If you reload a
servlet that's changed, the whole web-app gets dumped and the servlet is loaded
along with any classes it depends on.  So you'd be less likely to see this
problem with a servlet and JavaBean.

JSPs each have their own classloader.  When you reload a changed JSP, the only
thing that gets dumped is the classloader of the previous version of the JSP.
Any beans that are called by the JSP won't get dumped with the JSP.  So when the
JSP tries to reload the bean it wants, there's already another copy of the bean
in memory, which the JVM discovers when it tries to cast the newly loaded bean
class to the type specified by the JSP.  Does that make sense?  I may be wrong,
but I think it's something like that.  Anyone feel free to jump in and tweak my
explanation, please.

The workaround is to restart JRun when you change a bean or a JSP that loads a
bean (unless the bean hasn't been loaded yet), I think.  This sucks, but it's
something one of the developers is working on fixing.  It's a development-time
issue, not a production issue, but it also affects tag library class developers,
so we're working on it as a development enhancement.

Scott Stirling
Allaire

> -----Original Message-----
> From: Matt Goss [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 30, 2000 2:29 PM
>
>
> Hi everyone,
> HELP!!!!
> I'm working on a project where I add a bean (with an error msg) to the
> session from a servlet like this:
>         //adding error msg to bean
>            news.setErrormsg("Your directory has not yet been
> activated<br>please try again later");
>         //adding bean to session
>           req.getSession(true).putValue("news", news);
> and then forward to a jsp like this:
>         //sending to error page
>         RequestDispatcher rd =
> req.getRequestDispatcher("/newserror.jsp");
>          rd.forward(req, resp);
> the jsp gets the bean and displays the error like this:
>     <jsp:useBean id="news" scope="session"
> class="agcess.beans.newsletter.NewsLetterBean" />
>     <html>
>     <head>
>     <title>ERROR</title>
>     <DEFANGED_meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
>     </head>
>     <body bgcolor="#FFFFFF">
>     <h3><jsp:getProperty name="news" property="errormsg" /><h3>
>     </body>
>     </html>
>
>
> I intermittently get this error: (it goes away sometimes when I restart
> jrun)
>
> agcess.beans.newsletter.NewsLetterBean
> java.lang.ClassCastException: agcess.beans.newsletter.NewsLetterBean
>  at jrun__entry2ejspa._jspService(jrun__entry2ejspa.java:37)
>  at allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java:40)
>  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:174)
>  at allaire.jrun.servlet.JRunSE.service(JRunSE.java, Compiled Code)
>  at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code)

------------------------------------------------------------------------------
Archives: http://www.egroups.com/group/jrun-interest/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

begin:vcard 
n:Goss;Matt
tel;fax:919-657-1501
tel;work:919-657-1432
x-mozilla-html:FALSE
url:www.rtci.com
org:RTCI;Custom Solutions
adr:;;201 Shannon Oaks Circle;Cary;NC;27511;US
version:2.1
email;internet:[EMAIL PROTECTED]
title:Web Developer
fn:Matt
end:vcard

Reply via email to