Hi
I am trying to make an app where im using Hibernate, Spring and webservices (JWSDP).
Now my problem is that when i call my webservice from a client, then it seems that an instance of one of my beans get constructed outside the spring context !!!
I have set up the bean in the application context and can see that it is constructed at app startup by spring and gets all its dependencies injected correctly. But it is not the same bean i get later on when im constructing a new bean !!! Wich results in a nulll pointer in my app since the dependencies havent been injected !!!
What am i doing wrong ???
My web.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>LTD webservice</display-name>
<description>
blabla
</description>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>ltd-server.root</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/appContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.xml.rpc.server.http.JAXRPCContextLis tener</listener-class>
</listener>
<servlet>
<servlet-name>LokoService</servlet-name>
<display-name>LokoService</display-name>
<description>JAX-RPC endpoint - LokoService</description>
<servlet-class>com.sun.xml.rpc.server.http.JAXRPCServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>LokoService</servlet-name>
<url-pattern>/service</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
<!-- 30 minutes -->
</session-config>
</web-app>
My appcontext.xml looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource" singleton="true">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@ppdevdb2.dsb.dk:1527:LTDU DV</value>
</property>
<property name="username">
<value>LTD</value>
</property>
<property name="password">
<value>ltd</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean" singleton="true">
<property name="mappingResources">
<list>
<value>Lkf.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.O racle9Dialect</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">fal se</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<bean id="lokoManDao" class="dk.dsb.ltd.dao.LokoManagerDao" singleton="true">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="prodMan" class="dk.dsb.ltd.LokofoerServiceImpl" singleton="true" destroy-method="dispose" init-method="init">
<property name="lokoManagerDao">
<ref bean="lokoManDao"/>
</property>
</bean>
</beans>
The bean giving me all the problems is the one called prodMan...
(I have a feeling that it might be the JAXRPC servlet that somehow is constructing the beans outside spring context)
Id really appreciate some help here, any and all suggestions are welcome.
Thanks
Timm


Reply With Quote