File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
Author

[Spring + Java Web Service] bean property not injected

Cecilia Dewi Waty
Greenhorn

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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
Greenhorn

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="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
 
 
subject: [Spring + Java Web Service] bean property not injected