Getting MINA 2.0 to work peacefully in Glassfish

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

-Dcom.sun.enterprise.server.ss.ASQuickStartup=false

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 !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s