Results 1 to 2 of 2

Thread: Is it possible to share same Spring INSTANCE across WARs?

  1. #1
    Join Date
    Dec 2008
    Location
    India
    Posts
    295

    Default Is it possible to share same Spring INSTANCE across WARs?

    Hi All,

    I would like to know that can we share SAME Spring Bean Instance (created in x.WAR) to another war(y.WAR).

    In my application there are number of beans like HibernateSessionFactory, DataSource etc which are same in all wars. And still they are getting created multiple times(n times for n war).

    I want to share same bean instance across multiple war.

    How can we achieve this in Spring?

    Please note: I know how to share ApplicationContext across war using "parentContextKey" (here its example). This will just share same xml not the instance.
    Enjoy
    Rohan Chauhan
    ------------------------------------------------------------------------------
    SpringSource Certified Spring 3.0 Professional


  2. #2
    Join Date
    Dec 2009
    Location
    India
    Posts
    108

    Default

    Every WAR is a different application and spring context gets loaded for each application and therefore can't be shared. To reuse the DataSource & SessionFactory instance across multiple applications deployed in same application server, you need to configure these objects in JNDI and refer to those JNDI objects in different configuration within your application(s).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •