mercredi 24 juin 2015

Static Values are not visible in separate jars

In my web application, A value of static varialble located in a jar called "A" is changed in war . That newly changed value is visible and retains as it is. But whenever that variablel is accessed in another jar called "B", the updated value is not available, and first initialized value is only available.
For example:

// Default Ajar's static variable status;

 Ajar.Aclass.staticVariableA = "initializedValue";  

inside war, Ajar.Aclass.staticVariableA = "NewValue";  

// Then, when Bjar which is located in war also now access the Ajar's static variable,

 System.out.println("value in B jar : " + Ajar.Aclass.staticVariableA );

// This prints value in B jar : initializedValue

As I feel, the value of A.jar is valid in war file context as it is initialized inside the war. B.jar has its own context and whenever variables in A.jar is called, those variables'initial value is returned.

Is there a way to solve this ?

Aucun commentaire:

Enregistrer un commentaire