Jul 262013
 

I don’t use my local GlassFish much, so of course: I lost the admin password. Here’s a simple method to be able to log in again.

Start asadmin from the $GLASSFISH/bin folder.

asadmin> list-domains
domain1 not running
Command list-domains executed succesfully.

Next create a domain that does not exist yet. Supply an admin user and password that you can remember!

asadmin> create-domain
Enter the value for the domain_name operand> dummy
Enter admin user name [Enter to accept default "admin" / no password]> admin
Enter the admin password [Enter to accept default of no password]> ******
Enter the admin password again> ******
Using default port 4848 for Admin.
Using default port 8080 for HTTP Instance.
...
Domain dummy created.
Domain dummy admin port is 4848.
Domain dummy admin user is "admin".
Command create-domain executed successfully.
asadmin>

Now go to the config folder of domain dummy ($GLASSFISH/glassfish/domains/dummy/config). There is a file admin-keyfile. Copy this file to the config folder of your original domain, e.g. domain1 ($GLASSFISH/glassfish/domains/domain1/config). Make sure you make a backup of the original admin-keyfile first.

Confirm that you can log in as admin again. If so, you can safely delete the dummy-domain:

asadmin> delete-domain dummy
Domain dummy deleted.
Command delete-domain executed successfully.
asadmin>