I'm developing a simple JAX-WS application.
One of my web services endpoints has got injected object
@WebService(
endpointInterface = "com.kravchenko.service.ClientService",
targetNamespace = "http://com.kravchenko/wsdl"
)
@Named("clientServiceImpl")
public class ClientServiceImpl implements ClientService {
@Inject
ClientDAO clientDAO;
public void addClient(Client client) {
if (clientDAO == null) {
System.out.println("NULL CLIENTDAO");
}
clientDAO.addClient(client);
}
}
When I'm calling its addClient(Client client) method over soap it raises NPE.
My DAO is also very simple and looks like
@Singleton
public class ClientDAO {
public Map<Long,Client> clients= new ConcurrentHashMap<Long, Client>();;
public void addClient(Client client) {
clients.put(client.getId(),client);
}
}
I tried to injection type for setter injection, but it didn't work, too. I also tried to remove @Singleton and/or use other annotations like @ManagedBean or @Stateful, however , NPE still remains. I do have sun-jaxws.xml with 2 endpoints. I do have beans.xml in my project:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
All DAO methods work though if I declare it as CliendDAO dao = new ClientDAO();
But it's not the way I want my code to be formed.
my pom.xml has got only 2 dependencies:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
Any idea how can I solve this problem, please?