0

Hi I have a SOAP Handler class which is handling the logging for request which we get for a Webservice API. I am trying to insert this request in DB inside SOAP Handler. I have created DAOs which i m trying to inject through @Autowired annotation which are used to insert request in DB. But it is giving me Null Pointer Exception instead. Why does @Autowired not work here while it works perfectly well my @Service classes.

Naman
  • 129
  • 3
  • 13

1 Answers1

0

Was your SOAP Handler been instanciated by Spring ? Your @Service classes are read and instanciated by Spring at DI Container initialization, so the @Autowired can work.

So your handler need to be instancied by Spring to be managed (with a @Component-like annotation, for example). If it need to be instanciated by a Java EE container, you should consider extending SpringBeanAutowiringSupport

Regards

FabienM
  • 96
  • 1
  • 7
  • Well i tried the approach you mentioned. still the null pointer exception is persisting. tried with both extending SpringBeanAutowiringSupport as well as adding @Service annotation to the SoapHandler. – Naman Aug 20 '13 at 10:23
  • Is your class in the scope of your context configuration ? You may want to give a look at the question here : http://stackoverflow.com/questions/2943082/jax-ws-spring-and-springbeanautowiringsupport – FabienM Aug 20 '13 at 10:27
  • yes my class is in the context configuration. – Naman Aug 20 '13 at 12:02
  • this issue was solved by including SoapHandler class bean by usage of @Autowired annotation in Webservice Impl class. – Naman Aug 30 '13 at 07:35