• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

How to destroy Spring Application Context?

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Raju and Thanks Mark, it worked.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic