Tag Archives: bash

Issues with GlassFish on OSX

I’ve been trying to get GlassFish 4 to install on my laptop on and off for the past two days now. Needless to say, it’s not being going well. Initially I tried the native install (export DISPLAY=localhost:0.0 btw ­čÖé ), it hung trying to configure the domain. Trying to configure a new domain from the command line yielded:

./asadmin create-domain --adminport 4848 --instanceport 8000 domain2
You do not have permission to use port 4848 for domain2. Try a different port number or login to a more privileged account.

Nothing on port 4848 and even running the command as sudo root didn’t work. Next up, the zip install. The comes with a preconfigured domain and a new error trying to start it:

./asadmin start-domain domain1
There is a process already using the admin port of 4848 -- it probably is another instance of a GlassFish Server

Resorting to Google and I finally worked out that my hostname wasn’t in /etc/hosts. Being on the work network I’ve been assigned a hostname by the DHCP server rather than the sulaco.local it usually is. A quick google for setting the hostname on a Mac got me [this][http://blog.psyrendust.com/2008/05/23/change-the-hostname-in-mac-os-x-osx/] and I was able to run

sudo scutil --set HostName sulaco.local
./asadmin start-domain domain1

Lo and behold, GlassFish has started.

Sleep Sort

I may be late to the party here, but I was introduced to the Sleep Sort algorithm at Sync Conf last week. The code is deceptively simple:

function f() {
    sleep "$1"
    echo "$1"
while [ -n "$1" ]
    f "$1" &

Of course it’s also hideously inefficient. Using it to sort 3 1 4 1 5 is fine as it only takes 5 seconds, but I wouldn’t like to sort any number much over 10 as you could be there for some time. Does make me wonder if you could speed it up by using milliseconds rather than seconds… and at what point you start getting race conditions.