Vicky Rathee
Vicky Rathee

Reputation: 69

Change variables in an application in a live J2EE server using command line without doing s/s

I have an EJB application deployed on glassfish server. Using command line, I want to change value of some static variables in the live server without doing any stop start. Is there any way to do this.

Upvotes: 0

Views: 84

Answers (2)

Steve C
Steve C

Reputation: 19445

There is no way to do this in an existing application*.

You need to design and implement a mechanism for doing this yourself.

Possible techniques include:

  • Periodically checking a properties file and reloading it if it changes
  • Periodically checking a database table and reloading
  • Store the value in JNDI and look it up each time the value is required

* If you are completely desperate you could run in debug mode all the time and change the value in memory as needed by stopping the application at a suitable breakpoint.

Upvotes: 1

Niklas P
Niklas P

Reputation: 3507

You cannot change the code of a running application directly, so you need an interface. One possible interface can be the database. If the class with the static variables reads the value from the database, then you can create a small java client that updates the value in the database (per SQL update statement) and this way you can call the client per command line and give the new value per parameter on the command line.

Upvotes: 1

Related Questions