Sunday, December 14, 2008

Glassfish EJB3 remote interface on Linux problem

It's a problem struggles me for more than a year. Once I call a EJB Remote at Linux glassfish from any other machines, an strange exception will be thrown. The problem will only occur on Linux glassfish deployment. It was believed to be a bug as many other guys in glassfish forum). Here's the error messages:

"IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.0.1; port: 3700"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.(SocketOrChannelConnectionImpl.java:261)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.(SocketOrChannelConnectionImpl.java:274)


I come across this problem recently. After detail investigation, the problem is due of the Croba Connection on Linux Server resolve it's own ip address using the DNS name "localhost". The default Linux installation , /etc/host has the following line:
127.0.0.1 localhost

Then the client try to connect the server again using 127.0.0.1. The problem could be fixed by just modify the /etc/hosts file
{real ip address} localhost