aspose file tools*
The moose likes Spring and the fly likes How to destroy Spring Application Context? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to destroy Spring Application Context?" Watch "How to destroy Spring Application Context?" New topic
Author

How to destroy Spring Application Context?

Sagar Kale
Ranch Hand

Joined: May 02, 2008
Posts: 188
Hi,

Does anyone knows how to destroy Spring Application Context?

I create few resources in application context like RMI objects. When next time I run, I get error saying the port already in use. Then I have to close eclipse and start again for next testing. If I close Eclipse and run again, it does not give problem. But if I run once and run again without closing eclipse, I get error saying port is already in use. The application context does not get destroyed. How do I destroy application context?

Thanks
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Sagar Kale wrote: Hi,

Does anyone knows how to destroy Spring Application Context?

I create few resources in application context like RMI objects. When next time I run, I get error saying the port already in use. Then I have to close eclipse and start again for next testing. If I close Eclipse and run again, it does not give problem. But if I run once and run again without closing eclipse, I get error saying port is already in use. The application context does not get destroyed. How do I destroy application context?

Thanks


Just stop your server. How are you deploying, running your app. Obviously, that is still running, so you can just stop it.

Also, you can call close() on your applicationContext instance if you have a reference to it.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sagar Kale
Ranch Hand

Joined: May 02, 2008
Posts: 188
Thank you Mark.
It was a kind of r&d I was doing. It was not web applicaiton. It is standalone applicaiton. I did some research. Spring has api to create application context. But it does not give any way to destroy application context it might have done for some purpose.
Raju Penumatsa
Greenhorn

Joined: Mar 16, 2010
Posts: 5
Try this......

//Getting application context
ApplicationContext context = new ClassPathXmlApplicationContext(beansXML);

//cleaning context
((ClassPathXmlApplicationContext) context).close();
Sagar Kale
Ranch Hand

Joined: May 02, 2008
Posts: 188
Thanks Raju and Thanks Mark, it worked.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to destroy Spring Application Context?