Announcement Announcement Module
No announcement yet.
Loading spring in a web-app Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading spring in a web-app

    I'm trying to deploy Spring applications in different web-app's in the same host.

    When I put the spring jar's in a class-loader directly in the host the spring classes are shared between the webapp's. This has the effect that the hibernate sessionFactory instance is shared as well, wich causes all the web-apps to use the datasource of the last loaded web-app. Is this behaviour a bug?

    If I give each web-app a separate class-loader the web-app's won't start because the classes in that class-loader aren't available yet at the time it starts loading and tries to start up the ApplicationContext.

    Is there a way to work around this?

  • #2
    You should put all classes you use in your web app in the webapp's classloader (WEB-INF/lib). This way, you shouldn't have any problems. What server are you using?


    • #3
      I'm using Resin 3.0.8.

      I'm the only one using this server and I only deploy myself. Therefore I've put all the libs for the sites I deploy in a standard location for each version of the libs that is needed by a site so I don't have to upload 5-6 mb of libs everytime a new version of a site is deployed.

      Shouldn't a class-loader tag in the web-app have the same effect as placing the libs in WEB-INF/lib?


      • #4
        I think the classloader tag should work like that, but I'm not sure. I guess you'll have to resort to Resin's classloader architecture or its configuration doco to figure this out.

        My best bet is: keep dependencies close to the webapp (in WEB-INF/lib, the classloader tag in the host element in resin.conf, whatever), except for the usual: SQL drivers, security stuff configured in resin.conf itself, etcetera.