Announcement Announcement Module
Collapse
No announcement yet.
Multiple problem while sharing applicaitonContext using JAR, between multiple war Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple problem while sharing applicaitonContext using JAR, between multiple war

    Hi,
    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)
    Code:
    @Autowired
    CommonClass1 commonClass1
    But CommonClass2 is injected with same way(Which is defined by xml entries)
    Code:
    @Autowired
    CommonClass2 commonClass2
    "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)

    Code:
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    
    
        <!--
            - Location of the XML file that defines the root application context.
            - Applied by ContextLoaderServlet.
        -->
        <context-param>
            <param-name>parentContextKey</param-name>
            <param-value>common.context</param-value>
        </context-param>
        
        <context-param>
            <param-name>locatorFactorySelector</param-name>
            <param-value>classpath:beanRefContext.xml</param-value>
        </context-param>
        
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/context/common.xml</param-value>
        </context-param>
Working...
X