I have a very very strange problem here. I have a desktop application written with Spring 3.0.5-Release and Java 6.0. I’m also using Swing for the UI.
On startup, the application reads an application-context.xml file and instantiates a configuration bean from there, like this:
<bean id="config" class="my.blabla.Configuration">
<property name="port" value="5555"></property>
<property name="user" value="myUser"></property>
</bean>
In my application I’m using the properties from this Configuration bean.
Problem is now the following:
I package the application into a jar-file and deploy it on a machine.
I follow the following steps:
- In the
application-context.xmlI change the property user to userA. - Now I run the application. Everything runs fine. In the log-file property user shows userA.
-
I close the application.
-
In the
application-context.xmlI change the property user to userB. - I run the application. BUT In the log-file property user shows userA.
A few more infos. This does NOT happen when I debug the application. It only appears when the application is packaged and executed from command line.
I close my application via the default close button and have set this:
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Any idea, what is happening here? Is there a chance that spring beans somehow survive an application restart? Is there a chance that the java process is not shutdown?
I’m getting crazy. Any help is highly appreciated.
Are you running from the JAR file? Is the application context XML in that JAR file? Did you re-create the JAR after you change the bean from
userAtouserB? That would explain the mysterious behavior.Spring beans don’t survive a restart, any more than any in-memory value does. Your expectations don’t match reality.