flash
flash

Reputation: 6810

Spring Beans survive application restart?

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:

  1. In the application-context.xml I change the property user to userA.
  2. Now I run the application. Everything runs fine. In the log-file property user shows userA.
  3. I close the application.

  4. In the application-context.xml I change the property user to userB.

  5. 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.

Upvotes: 0

Views: 785

Answers (1)

duffymo
duffymo

Reputation: 308763

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 userA to userB? 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.

Upvotes: 2

Related Questions