Spring-Hibernate application: Illegal access: this web application instance has been stopped already

The problem you are facing is not related to database connections.

I guess you don't face this issue when you restart tomcat and don't redeploy the app, right?

The cause of it is redeploying the application in tomcat. Each time you redeploy the application new instance of a web application is created and the old one is stopped. There is probably an old class loaded by previous application somewhere or the application is not undeployed correctly.

Do you have some jar in tomcat/lib? Could you show the JobQuoteFormController and JobServiceImpl classes?


First, you probably want to use Spring's transaction manager and Hibernate's OpenSessionInViewFilter to manage Session's and transaction management. With those two you don't have to worry about managing connections and can grab a Session with itsSessionFactory.getCurrentSession().

Next, you should probably add p:testConnectionOnCheckout="true" to your dataSource bean.

What's happening with your application is that once a connection is dead it stays dead. This will allow a dead connection to be restarted.