Search code examples
springspring-web

How to use same context for multiple WARs?


I followed example in this link to use SingletonBeanFactoryLocator for using same bean in both WARs, but it seems two beans created NOT single.

I am getting below by hitting http://localhost:8080/War1/ and http://localhost:8080/War2/

Hello from SampleWeb1 using service instance com.interface21.sample.multiplecontexts.service.SampleServiceImpl@5cfbe4c4

Hello from SampleWeb2 using service instance com.interface21.sample.multiplecontexts.service.SampleServiceImpl@efa0fed

https://github.com/manojp1988/Learning/tree/JavaDSL/SingletonBeanFactoryLocatorEx

Can you please help me what I have done wrong.?


Solution

  • I have found the answer, since war has individual copy of jars, same bean didnt load. Once I have skinned the wars to use same copy of spring jars, i found it working. Spring MVC: Sharing context within ear