I am trying to share ApplicationContext between multiple war, using jar.Jar which contains 2 classes(CommonClass1,CommonClass2) and ApplicationContexts. The source code is attached with this thread.
CommonClass1 is defined using annotation
CommonClass2 is defined using Xml entry.
Now I am facing 2 strange problem.
1) CommonClass1 is not injected in my required war using (Throws beanNotFoundException)
But CommonClass2 is injected with same way(Which is defined by xml entries)
"So problem is Bean declared using annotation in jar are not accessible in wars"
2) In CommonClass2 which is injected, in this class i set a int value but that value is not available in another war. looks like instance not getting shared. (If it getting shared then value set in war1 should be accessible in war2, but here its returning default value that 0). "So problem is Instance not getting shared,only xml file getting shared by Jar"
Below is the code of my web.xml in war1(which is identical in war2)
- Location of the XML file that defines the root application context.
- Applied by ContextLoaderServlet.