My project consists of these basics.
1. WAR for my web app.
2. JAR for my business layer.
3. Packaged up into an EAR
In my business layer JAR I have declared /META-INF/spring/applicationContext.xml
In my web app WAR I have declared /WEB-INF/spring/applicationContext.xmlCode:<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean id="businessFacade" class="business.facade.BusinessFacadeImpl"/> </beans>
In my web app I have the following web.xmlCode:<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean id="categoriesTag" class="web.struts2.tags.CategoriesTag"> <property name="businessFacade"> <ref bean="businessFacade"/> </property> </bean> </beans>
ProblemCode:<web-app> <display-name>Web App</display-name> <filter> <filter-name>Struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>Struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Struts Tag Library Descriptors --> <taglib> <taglib-uri>/struts-tags</taglib-uri> <taglib-location>/WEB-INF/struts-tags.tld</taglib-location> </taglib> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/spring/applicationContext.xml classpath:/META-INF/spring/applicationContext.xml </param-value> </context-param> </web-app>
When I deploy the application the injection setter within CategoriesTag setBusinessFacade is called, and passed a valid instance of the Business Facade.
When I use the tag class within my JSP I get a null pointer exception telling me the business facade is null, which means this is a completely different instance.
What do I need to do to get the Spring created instance in my wep app?
Thanks


Reply With Quote