torek, 09. oktober 2012

Glassfish: Run asadmin from Java program

When you execute asadmin on a secure enabled server you have to provide admin username and password. This can be a bit of a PITA if you are calling asadmin from a Java program.
You have two options:

  1. Create $HOME/.asadminpass:
    asadmin://admin@localhost:4848 BASE64_ENCODED_PASSWORD
  2. Or you can pass the file with the password with every asadmin command:
    1. Create glassfisg.password file:
    2. If you are on Linux it is a good idea to make the file readable only to your user:
      chmod 600 glassfish.password
    3. Execute asadmin command:
      $com.sun.aas.installRoot/bin/asadmin --user admin --passwordfile PATH_TO_PASSWORD_FILE list-applications
$HOME is a home directory of a user under which Glassfish is running.
$com.sun.aas.installRoot is the installation directory of Glassfish. It is only set on a Glassfish process.
Objavite komentar