By arungupta on Jan 21, 2010
As explained in TOTD #118, one of the ways to manage OSGi bundles in GlassFish is by giving the command "telnet localhost 6666".
This straight forward command works fine if you installed either the Sun GlassFish Enterprise Server or the GlassFish community bits. The "domain.xml" in both of them is pre-configured for the telnet port to 6666 using the "jvm-options" as shown below:
However if you installed GlassFish as part of NetBeans 6.8, then you might see an error message as shown below:
C:\\Users\\Arun>telnet localhost 6666 Connecting To localhost...Could not open connection to the host, on port 6666: Connect failed
This error is more prominent in Windows Vista / 7 because of the Windows User Account Control (UAC). Or anywhere where GlassFish is installed in a directory that require root/administrator/sudo access to read/write. This Tip Of The Day will explain how to workaround this issue.
The default NetBeans installation directory is "C:\\Program Files\\NetBeans 6.8" and GlassFish goes in "C:\\Program Files\\sges-v3". At first start of NetBeans (typically as a non-Administrator), it tries to register the pre-configured domain in GlassFish installed in "C:\\Program Files". But the non-Adminstrator user do not have read/write access to "C:\\Program Files" and any sub-directories. So NetBeans create a new "personal" domain and assign a random port available at that moment for telnet. It shows all the ports assigned during the domain creation as shown below:
The image shows the port number "22007" for OSGI_SHELL.
How do you find that port later ? - Go to "Services" tab, expand "Servers", right-click on "Personal GlassFish v3 Domain", select "Properties" from the popup menu to see the following window:
The "Domains folder" shows the directory location of newly created domain and "Domain Name" has the domain name. The exact assigned port can be found by looking at "Domains folder"\\"Domain Name"\\config\\domain.xml. On my Windows7, it showed the following line:
So I tried "telnet localhost 22007" and voila, it worked!
Some other possible solutions that will work:
- Delete ".netbeans" directory and restart NetBeans by right-clicking on selecting "Run as administrator". This will provide the required rights for NetBeans to read/write "C:\\Program Files\\sges-v3\\glassfish\\domains\\domain1" directory. And so instead of creating a new "personal" domain, it'll register the existing domain in "\\Program Files\\sges-v3\\glassfish". Then "telnet localhost 6666" will work as expected.
- During NetBeans installation, specify GlassFish installation directory in a user directory such as:
This will ensure that NetBeans will have required privileges to read/write the "domains\\domain1" directory.
- Delete the "Personal GlassFish v3 Domain" and register a new instance that is already installed in a user directory.
- Disable UAC.
A complete archive of all the TOTDs is available here.