Hi,
I have an application which has an applicationContext.xml file:
This is part of it:
Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="po" class="com.a.b.domain.Po" /> <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass"><value>com.mysql.jdbc.Driver</value></property> <property name="jdbcUrl"><value>jdbc:mysql://localhost:3306/ripit</value></property> <property name="user"><value>user</value></property> <property name="password"><value>loser</value></property> </bean> <bean id="myPolicy" class="com.a.b.dao.jdbc.JdbcPolicy"> <property name="dataSource" ref="c3p0DataSource"/> </bean> <!-- JNDI DataSource for J2EE environments May need this to lookup datasource --> <bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/SurLines"/> </bean> </beans>
Here's part of the web.xml:
If in my initial controller I have a setter for the appcontext like this:Code:<display-name>surlines</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>surlines</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet>....
can the context be injected from the Meta data or am I still needing to declare it in the initial controller?Code:private ApplicationContext ctx; public void setCtx(ApplicationContext ctx) { this.ctx = ctx; }
I'm currently getting a Null Pointer when I try to do this, but I thought perhaps I was missing something; I probably need some sort of Bean to be injected...Sounds like a bad idea...
Thanks,
Peter...


Reply With Quote