Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 17265 invoked from network); 4 Oct 2010 13:18:45 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Oct 2010 13:18:45 -0000 Received: (qmail 24345 invoked by uid 500); 4 Oct 2010 13:18:41 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 23959 invoked by uid 500); 4 Oct 2010 13:18:39 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 23946 invoked by uid 99); 4 Oct 2010 13:18:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Oct 2010 13:18:38 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: 147.91.1.120 is neither permitted nor denied by domain of ognjen.d.blagojevic@gmail.com) Received: from [147.91.1.120] (HELO afrodita.rcub.bg.ac.rs) (147.91.1.120) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Oct 2010 13:18:31 +0000 Received: from [127.0.0.1] (ognjen-pc.rcub.bg.ac.rs [147.91.4.66]) by afrodita.rcub.bg.ac.rs (Postfix) with ESMTP id 157141919321 for ; Mon, 4 Oct 2010 15:17:55 +0200 (CEST) Message-ID: <4CA9D402.60706@gmail.com> Date: Mon, 04 Oct 2010 15:17:54 +0200 From: Ognjen Blagojevic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Serialization References: <4CA9D239.6050607@kfo-zmk.uni-kiel.de> <4638896.49.1286194082028.JavaMail.tomcat@localhost> <4CA9D8CC.3070208@kfo-zmk.uni-kiel.de> In-Reply-To: <4CA9D8CC.3070208@kfo-zmk.uni-kiel.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 101004-0, 10/04/2010), Outbound message X-Antivirus-Status: Clean X-RCUB-MailScanner-Information: Please contact the ISP for more information X-RCUB-MailScanner-ID: 157141919321.AB323 X-RCUB-MailScanner: Found to be clean X-RCUB-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-2.599, required 7, autolearn=not spam, BAYES_00 -2.60) If I understand correctly both ddm2 and dm5t are defined in .jsp files? If so, you could separate class definitions from .jsp files. -Ognjen On 4.10.2010 15:38, Wolfgang Orthuber wrote: > w4a.jsp and w4b.jsp are the names of two different jsp files. Both contain > <%@ include file="wtovedi.jsp" %> > and the file wtovedi.jsp contains the listed read and write code with > the definitions of ddm2. ddm2 is a rather complex object of objects, but > it contains no reference to w4a.jsp or w4b.jsp which are just filenames. > > Wolfgang > > > Am 04.10.2010 13:08, schrieb Ronald Klop: >> What does ddm2 look like? Does it have a reference to the jsp object? >> >> Ronald. >> >> >> Op maandag, 4 oktober 2010 15:10 schreef Wolfgang Orthuber >> : >>> >>> >>> Hello, >>> >>> my tomcat version is 5.5.17, my question concerns serialization of >>> objects, below is a code section for writing and reading an object. >>> If I call write immediately before read: >>> d5.write(); >>> d5.read(); >>> >>> then all works fine, but if I use only read (on an formerly written >>> file) with the same code included in another program module, I got >>> the exceptions like this: >>> java.lang.ClassCastException: org.apache.jsp.w.w4a_jsp$1ddm2 cannot >>> be cast to org.apache.jsp.w.w4b_jsp$1ddm2 >>> >>> in which w4a.jsp and w4b.jsp are two different modules which include >>> the same code for read and write. The name of the program module is >>> stored in the serialized object, but the name of the program module >>> does not matter, because both modules include the same code. >>> >>> Do you know a simple solution which avoids the exception? >>> >>> Wolfgang >>> >>> >>> >>> The code section with read and write: >>> >>> >>> class dm5t implements Serializable { >>> public ArrayList v5; >>> >>> public dm5t () { v5 = new ArrayList (); } >>> >>> public String topicpath(){return >>> getServletContext().getRealPath("")+"/tp/";} >>> >>> public synchronized boolean write () { >>> String fn=fntopics; >>> boolean ok=true; >>> try { >>> String spath = topicpath(); >>> >>> FileOutputStream fs = new FileOutputStream (spath+fn); >>> ObjectOutputStream os = new ObjectOutputStream (fs); >>> os.writeObject (v5); >>> os.close ();} >>> catch (IOException e) {ok=false;} return ok;} >>> >>> public synchronized boolean read () { >>> String fn=fntopics; >>> boolean ok=true; >>> ArrayList v5tmp=null; >>> try { >>> String spath = topicpath(); >>> >>> FileInputStream fs = new FileInputStream (spath+fn); >>> ObjectInputStream os = new ObjectInputStream (fs); >>> >>> v5tmp = (ArrayList) os.readObject (); >>> os.close (); >>> >>> } catch (IOException e) {ok=false;} >>> catch (ClassNotFoundException e) {ok=false;} >>> if (ok) if (v5tmp != null) v5=v5tmp; >>> return ok;} >>> } >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org >>> For additional commands, e-mail: users-help@tomcat.apache.org >>> >>> >>> >>> >>> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org