• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to destroy Spring Application Context?

 
Sagar Kale
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sagar Kale
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this......

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

//cleaning context
((ClassPathXmlApplicationContext) context).close();
 
Sagar Kale
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Raju and Thanks Mark, it worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic