lorelia
Aug 28th, 2005, 08:48 AM
Hello,
I have 2 projects. Both with "Spring Project Nature". In the second project I want to use beans from the first project. Therefore I've added the first project under the Project References and created a config set that holds the spring config file from the first project. I can see that config set in the second projcet under properties. So I thought everything would be alright. But it is not.
Is there anything more I have to add e.g. in my web.xml file? So far my web.xml file looks like this:
....
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>
<servlet>
<servlet-name>ldm</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/xml/ldm-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ldm</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/xml/common-data1.xml
</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value> config/internationalstrings
</param-value>
</context-param>
....
The referencened common-data1.xml looks like this:
...
<beans>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransa ctionManager">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
</bean>
<!-- sessionFactory and every other bean used in that project are configured in the springConfig.xml of the first project -->
</beans>
..
While deploying on JBOSS 3.2.6 there is an exception thrown caused by the entry "sessionFactory" in common-data1.xml. Because this bean couldn't be found. Although it is configured in the springConfig.xml file of the first project.
What is wrong here?
What, if I only want to use the springConfig.xml file from the first project, without any extra bean configuration in that
second project? I deleted the section "contextConfigLocation" in my web.xml and was hoping, that now only the referenced file from the config set would be taken. But this was not the
case! While deploying, a config file named "/WEB-INF/applicationContext.xml" had to be loaded. But of course I don't have such a file, because I wanna use my springConfig.xml from the first project. That caused an exception again. What can I do?
Thank you for your support
Lori
I have 2 projects. Both with "Spring Project Nature". In the second project I want to use beans from the first project. Therefore I've added the first project under the Project References and created a config set that holds the spring config file from the first project. I can see that config set in the second projcet under properties. So I thought everything would be alright. But it is not.
Is there anything more I have to add e.g. in my web.xml file? So far my web.xml file looks like this:
....
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>
<servlet>
<servlet-name>ldm</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/xml/ldm-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ldm</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/xml/common-data1.xml
</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value> config/internationalstrings
</param-value>
</context-param>
....
The referencened common-data1.xml looks like this:
...
<beans>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransa ctionManager">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
</bean>
<!-- sessionFactory and every other bean used in that project are configured in the springConfig.xml of the first project -->
</beans>
..
While deploying on JBOSS 3.2.6 there is an exception thrown caused by the entry "sessionFactory" in common-data1.xml. Because this bean couldn't be found. Although it is configured in the springConfig.xml file of the first project.
What is wrong here?
What, if I only want to use the springConfig.xml file from the first project, without any extra bean configuration in that
second project? I deleted the section "contextConfigLocation" in my web.xml and was hoping, that now only the referenced file from the config set would be taken. But this was not the
case! While deploying, a config file named "/WEB-INF/applicationContext.xml" had to be loaded. But of course I don't have such a file, because I wanna use my springConfig.xml from the first project. That caused an exception again. What can I do?
Thank you for your support
Lori