Got a “java.lang.InternalError:Can’t connect to window server” while trying to get Glassfish up and running on a Mac G5 running Mac OS X recently at work which was pretty odd as our application and Glassfish do not fire up any GUIs. After some googling, problem was fixed by adding a ‘-Djava.awt.headless=true’ to the list of system variables.
Although it was fixed relatively easily, it seems rather odd that Java would actually try to access the X server even though I was running it through a SSH terminal window (PuTTY)..