Archived

This forum has been archived. Please start a new discussion on GitHub.

IceGrid - Java system properties

Hi All,

I'm new to using IceGrid and have developed a small IceGrid application. My app has a main class that extends Ice.Application similar to the samples provided. However, unlike some of the samples, I'd like to dynamically resolve the config file used to to pass into the main method of the Ice.Application class.

For example,

int status = app.main("Server", args, <derivedConfigFile>);

When I start the application locally from eclipse, providing -Dserver.config=<filename> in the run configuration works fine. However, when I specify the same system property as an "option" element in the application descriptor, this does not work. The server instance doesn't recognize that a system property was set.

Application descriptor:

<server-template id="AuroraServer">
<parameter name="index" />
<server id="AuroraServer-${index}" exe="java" activation="on-demand">
<option>com.rbccm.rce.ice.AuroraServer</option>
<option>-Dserver.config=config.server.grid</option>
<env>CLASSPATH=./lib/*;%CLASSPATH%</env>
<property name="Identity" value="AuroraServer" />
</server>
</server-template>


First and foremost, is there a better way to do this? If not, is there something I'm doing wrong?

Thanks in advance for the help!

Jim

Comments

  • bernard
    bernard Jupiter, FL
    Hi Jim,

    Welcome to our forums!

    When you use IceGrid to manage a server (start, monitor, stop this server), IceGrid generates the Ice configuration file for this server from your description of this server.

    For example:
    <property name="Identity" value="AuroraServer" />
    

    will become
    Identity=AuroraServer
    
    in the config file that IceGrid generates for this server.

    When IceGrid launches the server, it passes --Ice.Config=<path to generated config file>, so it's critical that you give this argument to Ice (here the Ice.Application main method).
      // when launched with IceGrid, args contains --Ice.Config=...
       int status = app.main("Server", args);
    

    You don't need to pass your own config file or worry about finding the location of the file generated by IceGrid.

    I hope this is clearer now!

    Best regards,
    Bernard
  • Hi Bernard,

    Thank you for your help, it is indeed much clearer now! This has simplified things greatly for me.

    Thanks again,
    Jim