This weekend, I had some good opportunities to work on some cool things, one of which is build a Socket Server using Apache Mina 2.0(Release Candidate Version)…
Apparently, my project requires running two Socket Servers inside Glassfish v2, one to receive incoming client requests and the other as a simulator to receive what my application churns out.
I was happy to simply write a ServletContextListener which starts the Incoming Requests Socket Server in a separate Thread :). No Problems, I could connect to the Socket Server and communicate happily.
However, when I repeated the above steps to start the Simulator Socket Server(obviously listening in different port not conflicting with the previous Socket Server), server starts up fine. However, the minute I try to start communicating from a Socket Client to this Socket Server, the socket server started throwing a whole bunch of NullPointerException in NioSocketAcceptor.accept() method.
Why did this behavior not happen when I was running my first Socket Server but only happens with my second Socket Server. As usual Google came to my rescue at the wee hours too 😉
I was told to add the following property to my Glassfish JVM
Check this forum thread that helped me. Apparently this seems to be a bug in Glassfish v2 and has been fixed in V3. For Glassfish v2, the above property should help.
Glassfish Bug Database links related to this issue
Bug Id 3027
Bug Id 5321
I am still unable to understand why I did not have this problem when running first Socket Server inside Glassfish!!! One of those questions that still remains unanswered !
Didn’t I tell you that we had an exciting experience enabling cluster support for our applications using Glassfish.
Even though the entire setup worked fine in our local environment, life was not the same when trying to deploy our application on Amazon EC2 Cloud. We were greedy enough to pick a large machine with 8GB RAM and quad-core processors…and attempted to deploy our applications on the Glassfish Cluster there…
Our Server Instances would never start, failing with a whole bunch of NullPointerExceptions while creating JMS RA. I gave up after googling for couple of hours. And as usual, Venkat came to my rescue. He took over from me and spent some midnight oil and figured out the trick…
We had to add an unsupported property to the JVM…
Check out this link
from Ramesh Parthasarathy for more useful information related to this issue
Everytime I take up a task on adding Cluster Support to my j2ee application, the whole experience gets quite exciting with new kinds of challenges 🙂
In the past, it was with Weblogic, Websphere etc…and this time it was Glassfish 🙂
Ok, like many of you, I managed to setup the cluster environment in glassfish and deployed “ClusterJsp” application to check out Session Failover, Load balancing etc…
What I found was that, if I keep refreshing the ClusterJsp page 5 to 10 times, my Session Id keeps changing…going to say that Glassfish lost my session somewhere in between these requests.
After googling and bing’ing a lots, I managed to find this link
, which explained the issue in detail.
Basically, we should add the following snippet in sun-web.xml
After adding the above entry, Glassfish started behaving as expected.
Now what I donot quite understand is, why was this behavior not made a default behavior !!!
I am sure there is a good reason for it, will update If I get to know.