• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Spring + Java Web Service] bean property not injected

 
Cecilia Dewi Waty
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm developing a project using Hibernate + Spring + Java Web Service + Sun Application Server (Glassfish). My Hibnernate DAOs and Services work fine when I unit test them. I have a problem when I tried to test the web-service, all the DAOs that is being used by the web service that I'm calling is not being injected (hence I got null pointer exception).
My question is: how to make Spring aware that it has to handle bean property injection when I am calling the web service?


Thanks in advance

My service code is as follows (using Java Web Service annotation to make it into a web service):






web.xml








ApplicationContext.xml

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main question is : how is your myService bean fetched ? If it is not fetched via Spring, the dao will not be injected.
 
Darien Alvarez
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please can you explain your answer??? I have the same problem...

my applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns ="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet http://jax-ws.dev.java.net/spring/servlet.xsd">

<!-- **************************** Data access objects configuration **************************** -->


<bean id="jdbcPropertiesConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
</property>
</bean>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

<!-- ********************************** Data access objects ********************************** -->

<bean id="smsDAO" class="cu.uci.sams.pdu.sms.dao.impl.SmsDAOImpl">
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="tempsmsDAO" class="cu.uci.sams.pdu.sms.dao.impl.TempSmsDAOImpl">
<property name="dataSource" ref="dataSource" />
</bean>

<!-- ************************** Directory WebService Configuration ************************** -->

<wss:binding url="/services/SmsService">
<wss:service>
<ws:service bean="#smsWebService"/>
</wss:service>
</wss:binding>

<bean id="smsService" class="cu.uci.sams.pdu.sms.service.SmsServiceImpl">
<property name="sms" ref="smsDAO" />
<property name="tempsms" ref="tempsmsDAO" />
</bean>

<bean id="smsWebService" class="cu.uci.sams.pdu.sms.service.SmsWebService" />
</beans>


WEB.XML .....................................................

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>SmsWebServices</display-name>

<!-- ************************* Web services related configuration ************************* -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>

<servlet>
<servlet-name>serviceExporter</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>serviceExporter</servlet-name>
<url-pattern>/services/SmsService</url-pattern>
</servlet-mapping>

</web-app>

please help me
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic