Oops ... I meant Hortstman and Cornell's CoreJava book, not Cay's.
Lynn

Lynn Walton wrote:

> Here's my attempt at helping.....
>
> It's a serialization issue.  The jrun serializes your objects which are in
> sessions  when jrun shutsdown,  and tries to "unserialize" them to reinstantiate
> them when it starts back up.  If you don't specify a serialVersionUID in your
> changed class, as described below, then java's serialization mechanism makes
> it's own SHA fingerprint for the class that it stores when serializing an
> object.  When a class changes and an attempt is made to unserialize an older
> version of the class, the SHA fingerprint is different and it won't read in
> objects with different fingerprints.  The way to indicate that your new class is
> compatible with the old (if of course it is) is to obtain the fingerprint of the
> earlier version of the class using the serialver program that is a part of the
> JDK to obtain the number.
> >serialver yourpackage.YourClass
> outputs:
> yourpackage.YourClass: static final long serialVersionUID =
> _____________________L;
> You then put that line all later versions of your class.  This will cause the
> serialization mechanism to not compute the fingerprint manually but instead use
> that value.
>
> This is my paraphrase of information from Horstman and Cay's CoreJava book.
>
> Hope it helps you.
> Lynn
>
> Sid wrote:
>
> > I'm running windows2000 and JRun 3.0
> >
> > My servlet:
> > 1) Creates & populates an instance of my class called JournalEntry.
> > 2) puts it into the session,
> > 3) passes control to a JSP page for rendering
> >
> > Everything works fine, the class is passed to the JSP, and is displayed
> > properly.
> >
> > However, when I recompile the servlet, with the JRun server still running,
> > all subsequent requests throw an exception.
> > This applies to both existing and new sessions.  I must restart the jrun
> > server for it to work again.
> >
> > Thanks for any expert assistance!
> > Supporting info is below...
> > ============
> >
> > This is the error from the log...
> >
> > 03/20 08:45:00 info (JRun) journal.JournalMenu: init
> > 03/20 08:45:07 info (JRun) jrun__journalentry2ejsp11: init
> > 03/20 08:49:05 info (JRun) journal.JournalMenu: destroy
> > 03/20 08:49:05 info (session) Class change detected - reloading all session
> > data
> > 03/20 08:49:05 info (session) 3 session(s) persisted
> > 03/20 08:49:05 info (session) Recovering 3 session(s)
> > 03/20 08:49:05 info (JRun) journal.JournalMenu: init
> > 03/20 08:49:07 error (JRun) Couldnt pass to journalentry.jsp
> > [java.lang.ClassCastException: journal.JournalEntry]
> > java.lang.ClassCastException: journal.JournalEntry
> >  at jrun__journalentry2ejsp11._jspService(jrun__journalentry2ejsp11.java:39)
> >  at allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:40)
> >  at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
> >  at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
> >  at
> > allaire.jrun.servlet.JRunNamedDispatcher.forward(../servlet/JRunNamedDispatc
> > her.java:34)
> >  at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:175)
> >
> > Relevant code snippets below:
> > ============================
> > Servlet:
> >
> >   JournalEntry je = getJournalEntry(requestedId);
> >   HttpSession session = req.getSession();
> >   session.setAttribute("journalentry", je);
> >   ServletContext sc = this.getServletContext();
> >   RequestDispatcher rd = sc.getRequestDispatcher("/journalentry.jsp");
> >   if (rd != null) {
> >    try {
> >     rd.forward(req,res);
> >    } catch (Exception e) {
> >     sc.log("Couldnt pass to journalentry.jsp", e);
> >    }
> >   }
> >
> > JSP:
> >
> > <%
> >    journal.JournalEntry je =
> > (journal.JournalEntry)session.getAttribute("journalentry");
> >    URL url = je.getUrl();
> > %>
> > .....
> > <TR ALIGN="left" VALIGN=middle">
> >  <TD WIDTH="10%">ID</TD>
> >  <TD><%=je.getId()%></TD>
> > </TR>
> >
> > Archives: http://www.mail-archive.com/[email protected]/
> > Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to