Announcement Announcement Module
No announcement yet.
Re-Loding Spring classes programmatically Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Re-Loding Spring classes programmatically


    Just wanted to find out whats the best solution for this problem i have.

    We have a application where by each nite our database servers gets restarted.

    Now tomcat which is running Spring/Hibernate is broken everymorning as the jdbc connection that Spring/Hibernate is using is stale.
    We are using org.apache.commons.dbcp.BasicDataSource as our dataSoruce.

    We have some java code that runs everymorning and re-loads all java classes that we have for our web app.

    How can i get the Spring to reload?

    We have to restart tomcat everymorning to fix this broken jdbc connection.

    thanks in advance.

  • #2
    If your database restarts then I would recommend you restart tomcat too, since its going to leave those connections broken. I don't think there's any way around it. We have a similar setup ( not with spring though ) but we still have to restart both.

    Hope that helps.


    • #3
      You have to write your own connection pool based datasource that can manage the connection states though database upsets. It seems like a lot of work but it is worth the effort and really isn't that hard or complex.

      Alternatively, you can create a cluster and restart servers one at a time so there is no loss of service.


      • #4
        We are using the BasicDataSource and having a closer look at this class there was a property "validateQuery" which i used and it seems to work fine now.
        Thanks for all the tips...


        • #5
          I would say that's a much better idea, coupled with testOnBorrow (or one of the other test methods) that should solve the problem.

          Last edited by karldmoore; Aug 27th, 2007, 03:32 PM.