I'm using glassfish v2b43, and I have essentially tried this exact technique.
It appears to work...at first, it appears so. The IP address of the first client to hit the service is correctly logged.
If I then hit the service from a different machine, however, the IP address of the first machine is still logged.
My code is essentially the same as jitu has given here.
FWIW, glassfish v1 UR1 P01 also exhibits the same failure to correctly display the client's IP address.
[Message sent by forum member 'pohl' (pohl)]
http://forums.java.net/jive/thread.jspa?messageID=213272