I have a service that I've created using the Spring @Service annotation.  I am 
injecting Spring dependencies into the service using the @Inject annotation.  
When I invoke my service I get a NullPointerException when referencing the 
injected dependency (in this case a DAO).

@Service("userServiceImpl-2012-02-01")
@WebService(serviceName = "UserService",
name = "UserServicePort",
portName = "UserServicePort",
targetNamespace = 
"http://www.thomsonreuters.com/services/userservice/2012-02-01";)
public class UserServiceImpl implements UserService {

       @Inject
       private UserDAO userDAO;

       public UserCollectionResponse findUserByName(String userName) {
              Collection<com.thomsonreuters.persistence.User> 
userEntityCollection = userDAO.findByName(userName);

              UserCollectionResponse userCollectionResponse = new 
UserCollectionResponse();
              userCollectionResponse.userCollection = 
userConverter.convertToServiceObject(userEntityCollection);

              return userCollectionResponse;
       }
}

When I do the same via bean definition files, so services defined as bean in 
file and dependencies injected via the bean definition in the file, all works 
okay.

       <bean id="userServiceImpl-2012-02-01" 
class="com.thomsonreuters.services.userservice._2012_02_01.UserServiceImpl">
              <property name="userDAO" ref="userDAO"/>
              <property name="userConverter" ref="userConverter"/>
       </bean

      <jaxws:endpoint id="userServiceEndPoint-2012-02-01"
                                  implementor="#userServiceImpl-2012-02-01"
                                  address="/userservice/2012-02-01/userservice" 
wsdlLocation="UserService.wsdl">
              <jaxws:properties>
                     <entry key="schema-validation-enabled" value="true"/>
              </jaxws:properties>
       </jaxws:endpoint>

Anyone run into something like this?  I'm not sure how using the annotations 
instead of the file definitions would cause any issues.
Tom

Reply via email to