Application server - JBoss AS 7.1.1JDK6J2EE 1.3My web application is more than 10 years old and facing this session swap problem in my portal. Noticed that swap happens mostly when many concurrent users accessing the portal and underlying windows server is busy (more than 90% CPU usage)To analyse this issue, I logged customer data (customer id, ip address, jsession id) to a table and found that customer having unique jsession id initially has his data and all of a sudden for the same jsession id and ip address receiving different customer data.customer1  123.123.12.123   jsessionid123    11:10:02customer2  123.123.12.123   jsessionid123    11:10:04ip address (123.123.12.123) having jsession id (jsessionid123) somehow gets customer2 data Any order placed by customer1 in ip - 123.123.12.123 gets created for customer2, I confirmed this by calling customer2 and they confirmed that they didn't place the order. customer1 won't realise he placed order for customer2 - all the data gets changed, like basket items, customer object, products etc.Now I need to find a fix for this, but first I need to know which part of my code is creating this problem.Do I have to use a stress test software? or any better mechanism to find out the problematic code?
J2EE - Session swap
java;java ee;session
I found a fix for this problem. In my case, the in-house framework got the below code which caused the problem,        ...        req.setAttribute(key, value); /* This code gets executed for both REQUEST & SESSION */        if (scope == Sp.SESSION) {            req.getSession().setAttribute(key, value);            ...I noticed somehow the code maps session objects to incorrect jsessionid, so I tried the below code,         ...        if (scope == Sp.REQUEST) { /* Added this check */            req.setAttribute(key, value);        }        if (scope == Sp.SESSION) {            req.getSession().setAttribute(key, value);            ...It's nearly a year after this fix, and the swap didn't happen at all. So I'm confident this code fix solved the swap problem.