Can I run GlassFish as a non-root user (via package installer)?

  • Short answer
    yes.
  • Longer answer
    If you have installed GlassFish as root or via some installation package, the "default domains" are also owned by the root user. This means that you will not be able to start them, unless you are the root user.

But a "regular" user can create a domain that they own and can start. The user needs to create a "personal" domain. The create-domain command has the --domaindir option to help make this possible. The value for this option should be the path to a directory that the user owns. The domain will be created as a subdirectory of the domaindir.

Here is an example:

> mkdir $HOME/mydomains
> GLASSFISH_HOME/bin/asadmin create-domain --portbase 2112 --domaindir $HOME/mydomains testdomain
 ....
> ls $HOME/mydomains
testdomain

The user will need to use the --domaindir option to start and stop this "personal" domain, too.

Here is an example:

> GLASSFISH_HOME/bin/asadmin start-domain --domaindir $HOME/mydomains testdomain

Note: You may be tempted to just change file permissions to make the default domains startable. It can work but the odds of introducing hard to resolve errant behavior is pretty high. And the configuration you end up with is unsupported.