users@glassfish.java.net

Re: Solution

From: <glassfish_at_javadesktop.org>
Date: Sat, 18 Aug 2007 07:43:25 PDT

Hi.

This is for anyone there who has the same problem i had.
I found two possible solutions:

1)
Call the ServerSocket.setSocketFactory(SocketImplFactory) and replace the default ServerSocketFactory, with one of our own.

Probably we'll need ServerSocketFactory.createSocketImpl() to create a ServerSocket that implements SocketImpl, and we should change the ServerSocket.bind() to check if port is 0, if so change it with a port in the range we wish to.

This solution will not work with Glassfish running the lazy kernel (when jvm argument -Dcom.sun.enterprise.server.ss.ASQuickStartup is not set to false), because lazy kernel will do what i just explained, with a class called "ASServerSocketImpl".

2)
This solution is similar to the first, except we need to replace the ASServerSocket.bind() method to check for port == 0, and if so, choose the one we want. We should replace this class in both appserv-launch.jar and appserv-rt.jar (in the lib dir).

This is for GlassFish V1, i didn't test if V2.

Many thanks to all guys that helped me here.

Regards,

Alvaro.
[Message sent by forum member 'apunto' (apunto)]

http://forums.java.net/jive/thread.jspa?messageID=231490