aspose file tools*
The moose likes Web Services and the fly likes Service layer injection is not working after i exposed service layer as webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Service layer injection is not working after i exposed service layer as webservice" Watch "Service layer injection is not working after i exposed service layer as webservice" New topic
Author

Service layer injection is not working after i exposed service layer as webservice

Dilip Ganesh
Greenhorn

Joined: Sep 30, 2011
Posts: 24
Hi to all,

I have one service class to do the DB operations through the DAO classes , i inject the DAO object using spring. It is working fine.
After that i exposed the same service method as a webservice method using JAX-WS annotation. After that it is not working it saying my dao object not get injected , so i am getting nullpointerexception. the way i am doing is correct or not?

My Service class is




My Spring xml is




Please help me Thanks in advance
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
1. Your web service class is NOT managed/under control of Spring IoC container. So there is no DI. That's why NPE.

2. If you want your web service class to be mananged by Spring.
If you use Metro JAX-WS RI, then Metro JAX-WS RI ext has integration with Spring.
Spring will manage your web service class. So DI will be possible/OK.

See this sample
http://www.mkyong.com/webservices/jax-ws/jax-ws-spring-integration-example/

http://jax-ws-commons.java.net/spring/
Dilip Ganesh
Greenhorn

Joined: Sep 30, 2011
Posts: 24
Thank you so much for your guidance.
 
 
subject: Service layer injection is not working after i exposed service layer as webservice