Glassfish 4.1 won’t start in Yosemite 10.10.3
After upgrading to Yosemite 10.10.3, it appears that Glassfish will no longer start using the following command:
bin/asadmin start-domain domain1
JVM failed to start: com.sun.enterprise.admin.launcher.GFLauncherException: The server exited prematurely with exit code 0.
Before it died, it produced the following output:Command start-domain failed.
That’s slightly uncool. Not even an error message?
It turns out that the Glassfish team made an assumption that they could use launchctl bsexec in their nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java file.
This sub-command now requires root privileges.
Someone has submitted a patch to Glassfish trunk, but if you want to continue using Glassfish immediately, you can create this script somewhere e.g. ~/bin/launchctl.
#!/bin/bash
# A little hack to wrap launchctl in order to
# successfully start Glassfish on Yosemite 10.10.3+
if [[ ${1} == "bsexec" ]]; then
nohup ${@:3}
else
/bin/launchctl ${@}
fi
Remember to ‘chmod 755 ~/bin/launchctl’ so that it is executable.
Also remember that your ~/.profile or ~/.bash_profile must have something like this:
export PATH="$HOME/bin:$PATH"
The idea here is that this script is a wrapper for launchctl. As a user in Yosemite 10.10.3, you cannot run bsexec, but you may want to use launchctl for other things.