How to change the Admin port on Glassfish inside a script

10,841

You might want to do the following instead...

  1. install v3 by unzipping
  2. delete domain1
  3. create a new domain1 using the ports that you prefer. The man page for the create-domain subcommand will have all the details
  4. start this new domain...

No extra start or stop necessary (and you can skip step 2 if you are willing to remember to say 'asadmin start-domain mydomain' instead of 'asadmin start-domain'

Share:
10,841

Related videos on Youtube

Mat E.
Author by

Mat E.

Updated on June 04, 2022

Comments

  • Mat E.
    Mat E. about 2 years

    Got a weird Glassfish issue here. Here's how to reproduce it:

    (1) Install Glassfish v3
    (2) Start your default domain:

    $GLASSFISH_HOME/bin/asadmin start-domain domain1
    

    (3) Change the admin port (you'll need to enter admin uid & password, in our script we use the -u & -W parameters):

    $GLASSFISH_HOME/bin/asadmin set configs.config.server-config.network-config.network-listeners.network-listener.admin-listener.port=34848
    

    (4) Shut down the domain:

    $GLASSFISH_HOME/bin/asadmin stop-domain domain1
    

    You'll see this doesn't work. You get:

    CLI306 Warning - server is not running.
    Command stop-domain executed successfully.
    

    But your Glassfish process is still running. Worse, when you attempt to start the process you'll get a warning that some of your ports are already in use. Of course they are, the old process has still got 'em! Your only way out is killall -9 java

    While some of the config changes are dynamic it seems this one isn't but the domain stop assumes it is dynamic and uses the new port to try and execute the command.

    Possible solutions are:

    (1) Use sed on domain.xml - would prefer not to as it's complicated & risky grepping through XML code. I've seen Glassfish change the order of attributes in this file so we can't just sed for port="4848"
    (2) Use the scripted installer rather than the zip file and feed the parameters to the setup program as an answer file - this is problematic for our install scripts which are required to be idem potent.
    (3) Use a custom crafted zip of the Glassfish install archive with domain.xml already changed - not an option as the port we are setting may change in the future.

    This is almost the definition of a corner case but one we need to solve. For now we're going to sed domain.xml but it would be nice to know if there was a way that's possible via the CLI.