Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 72259 invoked from network); 3 Nov 2009 04:18:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Nov 2009 04:18:31 -0000 Received: (qmail 26798 invoked by uid 500); 3 Nov 2009 04:18:28 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 26578 invoked by uid 500); 3 Nov 2009 04:18:26 -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 26567 invoked by uid 99); 3 Nov 2009 04:18:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 04:18:25 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=FS_REPLICA,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of IHachem@lb.path-solutions.com designates 194.126.1.147 as permitted sender) Received: from [194.126.1.147] (HELO exchange.lb.path-solutions.com) (194.126.1.147) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 03 Nov 2009 04:18:15 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting empty Date: Tue, 3 Nov 2009 06:17:48 +0200 Message-ID: <17DB0F09A975D5458C80A38CD2B79456039ECB5E@exchange.lb.path-solutions.com> In-Reply-To: <4AEF3FF9.4040202@christopherschultz.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting empty Thread-Index: Acpb+pHuI9OXJKCtSruyUplciPouaQAdAhCw References: <17DB0F09A975D5458C80A38CD2B794560398EEA6@exchange.lb.path-solutions.com> <4AEEF837.5080509@christopherschultz.net> <17DB0F09A975D5458C80A38CD2B79456039ECAE2@exchange.lb.path-solutions.com> <4AEF3FF9.4040202@christopherschultz.net> From: "Imad Hachem" To: "Tomcat Users List" X-Virus-Checked: Checked by ClamAV on apache.org Dear Chris, has been set in my Web application web.xml and I have set as well the in the context.xml of both Tomcat Nodes but still not able to replicate my haspmap. Please find below QueryCryptUser.java source code: package com.guhesan.querycrypt.beans; import java.util.HashMap; import javax.crypto.SecretKey; public class QueryCryptUser implements java.io.Serializable { private String sessionID =3D ""; private HashMap md5Keys =3D new HashMap(); private SecretKey secretKey =3D null;=20 /** * @return Returns the md5Keys. */ public HashMap getMd5Keys() { return md5Keys; } /** * @param md5Keys The md5Keys to set. */ public void setMd5Keys(HashMap md5Keys) { this.md5Keys =3D md5Keys; } /** * @return Returns the sessionID. */ public String getSessionID() { return sessionID; } /** * @param sessionID The sessionID to set. */ public void setSessionID(String sessionID) { this.sessionID =3D sessionID; } =09 public void addToMD5Map(String md5, byte[] encryptedStr) { this.md5Keys.put(md5, encryptedStr); } =09 public byte[] getByKey(String md5key) { return (byte[]) this.md5Keys.get(md5key); } /** * @return Returns the secretKey. */ public SecretKey getSecretKey() { return secretKey; } /** * @param secretKey The secretKey to set. */ public void setSecretKey(SecretKey secretKey) { this.secretKey =3D secretKey; } =09 public QueryCryptUser(String sessionid, SecretKey key) { super(); // TODO Auto-generated constructor stub secretKey =3D key; sessionID =3D sessionid; } =09 =09 } Imad Hachem | Asst.Product Development Manager e-Banking Department Path Solutions Tel: +961 1 697444 ext. 222 Fax: +961 1 696744 www.path-solutions.com Disclaimer [The information contained in this e-mail message and any attached files are confidential information and intended solely for the use of the individual or entity to whom they are addressed. This transmission may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you have received this e-mail in error, please notify the sender immediately and delete all copies. If you are not the intended recipient, any disclosure, copying, distribution, or use of the information contained herein is STRICTLY PROHIBITED. Path Solutions accepts no responsibility for any errors, omissions, computer viruses and other defects.] =20 =20 =20 -----Original Message----- From: Christopher Schultz [mailto:chris@christopherschultz.net]=20 Sent: Monday, November 02, 2009 10:24 PM To: Tomcat Users List Subject: Re: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting empty -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Imad, On 11/2/2009 12:33 PM, Imad Hachem wrote: > You are right about the case of Tomcat Node non shutdown, HashMap is not > replicated correctly to the other node. Okay, good (sort of). If it was only failing on one-node shutdown, it would be much messier to track this down. Instead, this one attribute (or perhaps more) are simply failing to replicate properly. > Note that I am saving a secretKey (javax.crypto.SecretKey) as a VALUE > for the sessionid KEY stored in the HashMap. Do you have set in your web.xml? If not, you should enable this. Doing so should cause an IllegalArgumentException to be thrown if you try to put something into the session that isn't Serializable. Note that the above statement only apples to values explicitly stored in the session. This, for instance, will cause an error: HttpSession session =3D request.getSession(true); session.put("someKey", new NonSerializableClass()); ...while this will not: HttpSession session =3D request.getSession(true); HashMap map =3D new HashMap(); map.put("someOtherKey", new NonSerializableClass()); session.put("someKey", map); so, you have to be careful that the full object trees you put into your session are serializable in their entirety. You could write a filter that checks all this if you wanted to. > How can I make sure that this secretKey or all HaspMap data are > serializable? Well, javax.crypto.SecretKey is not itself required to be serializable, but one of its implementations, SecretKeySpec, /is/ marked as Serializable. Any idea what kind of object you actually have? > Note I am using the below code to store in the HashMap: >=20 > static HashMap userSessionMapArray =3D new HashMap(); > SecretKey b =3D > KeyGenerator.getInstance("DESede").generateKey(); > QueryCryptUser qcu =3D new QueryCryptUser(sessionID, b); > userSessionMapArray.put(sessionID, qcu); >=20 >=20 > Note that I have tried to create the "QueryCryptUser" Class to > implements java.io.Serializable but still facing the same problem and > HashMap not replicated to the 2nd Node. Well, would you be comfortable putting the key text itself into the session? The key text itself should just be a byte[] which you could convert to char[] in a number of ways if you'd like to make it (human) readable. I agree with Pid's question: why is the array static? ...and what it is static to? Clearly, your QueryCryptUser object needs to be Serializable, so you should really focus on that, I think. You can encapsulate the logic to serialize your SecretKey object within your QueryCryptUser class. Can you post some or all of the QueryCryptUser class code? Are you getting any errors in your log files when these objects are serialized? It might help alot to see what the JVM is refusing to serialize. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkrvP/kACgkQ9CaO5/Lv0PDKEwCgr2zMyPXLl0teiHA4KhJwTh7g pVgAmgLKL5nT+ksy7xyeekvIT/ujJmNR =3DzM1q -----END PGP SIGNATURE----- --------------------------------------------------------------------- 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