|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
RE: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting emptyDear Team, After setting a Tomcat Cluster of 2 nodes on separate machine, Session replication is working very fine except one library objects (QueryCrypt.jar included in this Web Project) having a Hashmap where we store Users SESSION ID. After one node shutdown, this Hashmap object is getting empty, note that all other session variables have been replicated successfully and SESSIONID.jvmRoute still the same which is correct and expected behavior. I have tried to add <Context distributable="true"> in both Tomcat context.xml files and even tried to add <distributable/> to the web.xml of the Component Project that I am using (QueryCrypt.jar containing a Startup Servlet) but still facing the same problem and the Hashmap object used as a table to store Users session ids is getting empty. How can I force this Hashmap object to be replicated to the 2nd Tomcat node since the session still alive and been redirected to the 2nd Tomcat Cluster node. Please help and thanks in advance. 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 <http://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.] |
|
|
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/1/2009 1:41 AM, Imad Hachem wrote: > After setting a Tomcat Cluster of 2 nodes on separate machine, Session > replication is working very fine except one library objects > (QueryCrypt.jar included in this Web Project) having a Hashmap where we > store Users SESSION ID. > > After one node shutdown, this Hashmap object is getting empty, note that > all other session variables have been replicated successfully and > SESSIONID.jvmRoute still the same which is correct and expected > behavior. If that node does /not/ shut down, can you observe that the HashMap is correctly replicated to the other node? I suspect not. My guess is that your HashMap has data other than just the SESSIONID, and that data is not serializable. Can you run this code against your HashMap in the session? Map map = (Map)session.getAttribute("whatever"); for(Iterator i=map.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry)i; Object key = entry.getKey(); Object value = entry.getValue(); System.out.print(key); System.out.print(" ("); System.out.print((null == key ? "null" : key.getClass().getName())); System.out.print(") -> "); System.out.print(value); System.out.print(" ("); System.out.print((null == value ? "null" : value.getClass().getName())); System.out.println(")"); } - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkru+DcACgkQ9CaO5/Lv0PAfgACbB7Vu9eKS/9rrfhYxqoBcKnv+ ARQAoKFbk70KLHU/dh+0CypVk839V2ku =Vz81 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
RE: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting emptyDear chris,
Thanks for your reply. You are right about the case of Tomcat Node non shutdown, HashMap is not replicated correctly to the other node. Note that I am saving a secretKey (javax.crypto.SecretKey) as a VALUE for the sessionid KEY stored in the HashMap. How can I make sure that this secretKey or all HaspMap data are serializable? Note I am using the below code to store in the HashMap: static HashMap userSessionMapArray = new HashMap(); SecretKey b = KeyGenerator.getInstance("DESede").generateKey(); QueryCryptUser qcu = new QueryCryptUser(sessionID, b); userSessionMapArray.put(sessionID, qcu); 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. 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.] -----Original Message----- From: Christopher Schultz [mailto:chris@...] Sent: Monday, November 02, 2009 5:18 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/1/2009 1:41 AM, Imad Hachem wrote: > After setting a Tomcat Cluster of 2 nodes on separate machine, Session > replication is working very fine except one library objects > (QueryCrypt.jar included in this Web Project) having a Hashmap where we > store Users SESSION ID. > > After one node shutdown, this Hashmap object is getting empty, note that > all other session variables have been replicated successfully and > SESSIONID.jvmRoute still the same which is correct and expected > behavior. If that node does /not/ shut down, can you observe that the HashMap is correctly replicated to the other node? I suspect not. My guess is that your HashMap has data other than just the SESSIONID, and that data is not serializable. Can you run this code against your HashMap in the session? Map map = (Map)session.getAttribute("whatever"); for(Iterator i=map.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry)i; Object key = entry.getKey(); Object value = entry.getValue(); System.out.print(key); System.out.print(" ("); System.out.print((null == key ? "null" : key.getClass().getName())); System.out.print(") -> "); System.out.print(value); System.out.print(" ("); System.out.print((null == value ? "null" : value.getClass().getName())); System.out.println(")"); } - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkru+DcACgkQ9CaO5/Lv0PAfgACbB7Vu9eKS/9rrfhYxqoBcKnv+ ARQAoKFbk70KLHU/dh+0CypVk839V2ku =Vz81 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting emptyOn 02/11/2009 17:33, Imad Hachem wrote:
> Dear chris, > > Thanks for your reply. > > You are right about the case of Tomcat Node non shutdown, HashMap is not > replicated correctly to the other node. > > Note that I am saving a secretKey (javax.crypto.SecretKey) as a VALUE > for the sessionid KEY stored in the HashMap. > > How can I make sure that this secretKey or all HaspMap data are > serializable? > > Note I am using the below code to store in the HashMap: > > static HashMap userSessionMapArray = new HashMap(); > SecretKey b = > KeyGenerator.getInstance("DESede").generateKey(); > QueryCryptUser qcu = new QueryCryptUser(sessionID, b); > userSessionMapArray.put(sessionID, qcu); Why is the HashMap static? I don't think the code above will cause anything to replicate. > 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. Are you storing the QueryCryptUser, or the HashMap in an HTTPSession somewhere else? What is it that you are actually trying to achieve? p > 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.] > > > > > -----Original Message----- > From: Christopher Schultz [mailto:chris@...] > Sent: Monday, November 02, 2009 5:18 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/1/2009 1:41 AM, Imad Hachem wrote: >> After setting a Tomcat Cluster of 2 nodes on separate machine, Session >> replication is working very fine except one library objects >> (QueryCrypt.jar included in this Web Project) having a Hashmap where > we >> store Users SESSION ID. >> >> After one node shutdown, this Hashmap object is getting empty, note > that >> all other session variables have been replicated successfully and >> SESSIONID.jvmRoute still the same which is correct and expected >> behavior. > > If that node does /not/ shut down, can you observe that the HashMap is > correctly replicated to the other node? I suspect not. > > My guess is that your HashMap has data other than just the SESSIONID, > and that data is not serializable. > > Can you run this code against your HashMap in the session? > > Map map = (Map)session.getAttribute("whatever"); > > for(Iterator i=map.entrySet().iterator(); i.hasNext(); ) > { > Map.Entry entry = (Map.Entry)i; > > Object key = entry.getKey(); > Object value = entry.getValue(); > > System.out.print(key); > System.out.print(" ("); > System.out.print((null == key ? "null" : key.getClass().getName())); > System.out.print(") -> "); > > System.out.print(value); > System.out.print(" ("); > System.out.print((null == value > ? "null" > : value.getClass().getName())); > System.out.println(")"); > } > > - -chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAkru+DcACgkQ9CaO5/Lv0PAfgACbB7Vu9eKS/9rrfhYxqoBcKnv+ > ARQAoKFbk70KLHU/dh+0CypVk839V2ku > =Vz81 > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
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 <distributable/> 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 = request.getSession(true); session.put("someKey", new NonSerializableClass()); ...while this will not: HttpSession session = request.getSession(true); HashMap map = 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: > > static HashMap userSessionMapArray = new HashMap(); > SecretKey b = > KeyGenerator.getInstance("DESede").generateKey(); > QueryCryptUser qcu = new QueryCryptUser(sessionID, b); > userSessionMapArray.put(sessionID, qcu); > > > 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 =zM1q -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
RE: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting emptyHi Pid,
Thanks for your reply. I am using a URL Encrytion/Decryption Open Source Library called "QueryCrypt", and HaspMap object has been declared in this Library as Static. QueryCrypt Library is based on HashMap where it has been used to store Users SESSIONIDs and Encryption KEYs. For each user we are inserting an Entry (Key=SESSIONID, VALUE=Encryption_key) after an encryption Call of One URL String. After a Decryption Call, QueryCrypt fetch the HashMap table and retrieve the "Encryption_key" for the related "SESSIONID". What is happening, the HasMap table is not replicated at all between Clustered Tomcats, and after Decryption I am loosing and not able to Retrieve my "Encryption_key" in order to Decrypt my URL String. Are you suggesting to Store the HashMap and QueryCryptUser objects to the HTTPSession in order to be retrieved later on or just to store them on the session to force the HashMap to be replicated? 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.] -----Original Message----- From: Pid [mailto:pid@...] Sent: Monday, November 02, 2009 8:30 PM To: users@... Subject: Re: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting empty On 02/11/2009 17:33, Imad Hachem wrote: > Dear chris, > > Thanks for your reply. > > You are right about the case of Tomcat Node non shutdown, HashMap is not > replicated correctly to the other node. > > Note that I am saving a secretKey (javax.crypto.SecretKey) as a VALUE > for the sessionid KEY stored in the HashMap. > > How can I make sure that this secretKey or all HaspMap data are > serializable? > > Note I am using the below code to store in the HashMap: > > static HashMap userSessionMapArray = new HashMap(); > SecretKey b = > KeyGenerator.getInstance("DESede").generateKey(); > QueryCryptUser qcu = new QueryCryptUser(sessionID, b); > userSessionMapArray.put(sessionID, qcu); Why is the HashMap static? I don't think the code above will cause anything to replicate. > 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. Are you storing the QueryCryptUser, or the HashMap in an HTTPSession somewhere else? What is it that you are actually trying to achieve? p > 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 > 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.] > > > > > -----Original Message----- > From: Christopher Schultz [mailto:chris@...] > Sent: Monday, November 02, 2009 5:18 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/1/2009 1:41 AM, Imad Hachem wrote: >> After setting a Tomcat Cluster of 2 nodes on separate machine, >> replication is working very fine except one library objects >> (QueryCrypt.jar included in this Web Project) having a Hashmap where > we >> store Users SESSION ID. >> >> After one node shutdown, this Hashmap object is getting empty, note > that >> all other session variables have been replicated successfully and >> SESSIONID.jvmRoute still the same which is correct and expected >> behavior. > > If that node does /not/ shut down, can you observe that the HashMap is > correctly replicated to the other node? I suspect not. > > My guess is that your HashMap has data other than just the SESSIONID, > and that data is not serializable. > > Can you run this code against your HashMap in the session? > > Map map = (Map)session.getAttribute("whatever"); > > for(Iterator i=map.entrySet().iterator(); i.hasNext(); ) > { > Map.Entry entry = (Map.Entry)i; > > Object key = entry.getKey(); > Object value = entry.getValue(); > > System.out.print(key); > System.out.print(" ("); > System.out.print((null == key ? "null" : > System.out.print(") -> "); > > System.out.print(value); > System.out.print(" ("); > System.out.print((null == value > ? "null" > : value.getClass().getName())); > System.out.println(")"); > } > > - -chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAkru+DcACgkQ9CaO5/Lv0PAfgACbB7Vu9eKS/9rrfhYxqoBcKnv+ > ARQAoKFbk70KLHU/dh+0CypVk839V2ku > =Vz81 > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
RE: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting emptyDear Chris,
<distributable/> has been set in my Web application web.xml and I have set as well the <Context distributable="true"> 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 = ""; private HashMap md5Keys = new HashMap(); private SecretKey secretKey = null; /** * @return Returns the md5Keys. */ public HashMap getMd5Keys() { return md5Keys; } /** * @param md5Keys The md5Keys to set. */ public void setMd5Keys(HashMap md5Keys) { this.md5Keys = md5Keys; } /** * @return Returns the sessionID. */ public String getSessionID() { return sessionID; } /** * @param sessionID The sessionID to set. */ public void setSessionID(String sessionID) { this.sessionID = sessionID; } public void addToMD5Map(String md5, byte[] encryptedStr) { this.md5Keys.put(md5, encryptedStr); } 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 = secretKey; } public QueryCryptUser(String sessionid, SecretKey key) { super(); // TODO Auto-generated constructor stub secretKey = key; sessionID = sessionid; } } 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.] -----Original Message----- From: Christopher Schultz [mailto:chris@...] 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 <distributable/> 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 = request.getSession(true); session.put("someKey", new NonSerializableClass()); ...while this will not: HttpSession session = request.getSession(true); HashMap map = 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: > > static HashMap userSessionMapArray = new HashMap(); > SecretKey b = > KeyGenerator.getInstance("DESede").generateKey(); > QueryCryptUser qcu = new QueryCryptUser(sessionID, b); > userSessionMapArray.put(sessionID, qcu); > > > 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 =zM1q -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
RE: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting emptyDear Chris / Pid,
Issue has been solved after setting both hashmap & QueryCryptUser objects to the Session as below: static HashMap userSessionMapArray = new HashMap(); SecretKey b = KeyGenerator.getInstance("DESede").generateKey(); QueryCryptUser qcu = new QueryCryptUser(sessionID, b); userSessionMapArray.put(sessionID, qcu); request.getSession().setAttribute("userSessionMapArray",userSessionMapAr ray; request.getSession().setAttribute("qcu", qcu); Thanks for your help 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.] -----Original Message----- From: Imad Hachem Sent: Tuesday, November 03, 2009 12:21 PM To: 'Tomcat Users List' Subject: RE: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting empty Dear Chris, <distributable/> has been set in my Web application web.xml and I have set as well the <Context distributable="true"> 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 = ""; private HashMap md5Keys = new HashMap(); private SecretKey secretKey = null; /** * @return Returns the md5Keys. */ public HashMap getMd5Keys() { return md5Keys; } /** * @param md5Keys The md5Keys to set. */ public void setMd5Keys(HashMap md5Keys) { this.md5Keys = md5Keys; } /** * @return Returns the sessionID. */ public String getSessionID() { return sessionID; } /** * @param sessionID The sessionID to set. */ public void setSessionID(String sessionID) { this.sessionID = sessionID; } public void addToMD5Map(String md5, byte[] encryptedStr) { this.md5Keys.put(md5, encryptedStr); } 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 = secretKey; } public QueryCryptUser(String sessionid, SecretKey key) { super(); // TODO Auto-generated constructor stub secretKey = key; sessionID = sessionid; } } 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.] -----Original Message----- From: Christopher Schultz [mailto:chris@...] 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 <distributable/> 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 = request.getSession(true); session.put("someKey", new NonSerializableClass()); ...while this will not: HttpSession session = request.getSession(true); HashMap map = 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: > > static HashMap userSessionMapArray = new HashMap(); > SecretKey b = > KeyGenerator.getInstance("DESede").generateKey(); > QueryCryptUser qcu = new QueryCryptUser(sessionID, b); > userSessionMapArray.put(sessionID, qcu); > > > 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 =zM1q -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: MISC; After one Tomcat Cluster node shutdown Session Replication working but a Hashmap object is getting emptyOn 03/11/2009 08:13, Imad Hachem wrote:
> Dear Chris / Pid, > > Issue has been solved after setting both hashmap& QueryCryptUser > objects to the Session as below: > > static HashMap userSessionMapArray = new HashMap(); > SecretKey b = KeyGenerator.getInstance("DESede").generateKey(); > QueryCryptUser qcu = new QueryCryptUser(sessionID, b); > userSessionMapArray.put(sessionID, qcu); > > request.getSession().setAttribute("userSessionMapArray",userSessionMapAr > ray; > request.getSession().setAttribute("qcu", qcu); > > Thanks for your help I still don't understand why the HashMap is marked static - I don't see that it will do anything - try removing that and seeing if it works. I also don't understand, if you're adding the QueryCryptUser to the session, and it contains the SecretKey 'b' already, why do you need the HashMap? It doesn't contain other users session ids does it? p > 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.] > > > > > -----Original Message----- > From: Imad Hachem > Sent: Tuesday, November 03, 2009 12:21 PM > To: 'Tomcat Users List' > Subject: RE: MISC; After one Tomcat Cluster node shutdown Session > Replication working but a Hashmap object is getting empty > > Dear Chris, > > <distributable/> has been set in my Web application web.xml and I have > set as well the<Context distributable="true"> 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 = ""; > private HashMap md5Keys = new HashMap(); > private SecretKey secretKey = null; > /** > * @return Returns the md5Keys. > */ > public HashMap getMd5Keys() > { > return md5Keys; > } > /** > * @param md5Keys The md5Keys to set. > */ > public void setMd5Keys(HashMap md5Keys) > { > this.md5Keys = md5Keys; > } > /** > * @return Returns the sessionID. > */ > public String getSessionID() > { > return sessionID; > } > /** > * @param sessionID The sessionID to set. > */ > public void setSessionID(String sessionID) > { > this.sessionID = sessionID; > } > > public void addToMD5Map(String md5, byte[] encryptedStr) > { > this.md5Keys.put(md5, encryptedStr); > } > > 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 = secretKey; > } > > public QueryCryptUser(String sessionid, SecretKey key) > { > super(); > // TODO Auto-generated constructor stub > secretKey = key; > sessionID = sessionid; > } > > > } > > > 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.] > > > > > -----Original Message----- > From: Christopher Schultz [mailto:chris@...] > 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<distributable/> 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 = request.getSession(true); > session.put("someKey", new NonSerializableClass()); > > ...while this will not: > > HttpSession session = request.getSession(true); > HashMap map = 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: >> >> static HashMap userSessionMapArray = new HashMap(); >> SecretKey b = >> KeyGenerator.getInstance("DESede").generateKey(); >> QueryCryptUser qcu = new QueryCryptUser(sessionID, b); >> userSessionMapArray.put(sessionID, qcu); >> >> >> 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 > =zM1q > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
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 11:17 PM, Imad Hachem wrote: > <distributable/> has been set in my Web application web.xml Okay, make sure it stays that way. > private String sessionID = ""; > private HashMap md5Keys = new HashMap(); > private SecretKey secretKey = null; String and HashMap (as long as you don't store non-serializable objects in it) are both Serializable. Since SecretKey is not itself Serializable, you might want to customize the serialization of this class. If the SecretKey object itself is serializable, go ahead and use Java's serialization. Otherwise, manually serialize it using SecretKey.toEncoded() or something like that. > public QueryCryptUser(String sessionid, SecretKey key) > { > super(); > // TODO Auto-generated constructor stub > secretKey = key; > sessionID = sessionid; > } In order to allow de-serialization, your class must have a no-arg constructor. Read a tutorial on Java Serialization such as this one: http://www.j2ee.me/developer/technicalArticles/Programming/serialization/ ...and I think it may help you fix your classes to they may be replicated successfully across your cluster. Good luck, - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkrwjIwACgkQ9CaO5/Lv0PDeawCghgS3ztc5UCCrJuKO8EE7caWc iRMAnRp3M8c1Bn1L421oWXDlNe57LCJf =lQRZ -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |