In a spring MVC application, I initialize a variable in one of the service classes using the following approach:
ApplicationContext context =
new C
If you are using the ClassPathXmlApplicationContext then you can use
((ClassPathXmlApplicationContext) context).close();
to close the resource leak problem.
If you are using the AbstractApplicationContext then you can cast this with close method.
((AbstractApplicationContext) context).close();
It depends on the type of context using in the application.