File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes [Spring + Java Web Service] bean property not injected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "[Spring + Java Web Service] bean property not injected" Watch "[Spring + Java Web Service] bean property not injected" New topic

[Spring + Java Web Service] bean property not injected

Cecilia Dewi Waty

Joined: Apr 11, 2007
Posts: 1
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):



Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

The main question is : how is your myService bean fetched ? If it is not fetched via Spring, the dao will not be injected.

[My Blog]
All roads lead to JavaRanch
Darien Alvarez

Joined: Aug 16, 2008
Posts: 2
Please can you explain your answer??? I have the same problem...

my applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
xmlns =""

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

<bean id="jdbcPropertiesConfigurer"
<property name="location">

<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}" />

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

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

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

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

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

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

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

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

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"


<!-- ************************* Web services related configuration ************************* -->





please help me
I agree. Here's the link:
subject: [Spring + Java Web Service] bean property not injected
It's not a secret anymore!