My project is a Web Dynamic Project I am using JSF 2.2 with CDI in tomcat 7.0. The CDI is working well for my beans, but when I try to use the @Inject
for my Web Service class it is returning null
.
@Named
public class SchoolDataWS {
@Inject
private SchoolDataDAO dao;
public SchoolDataWS() {
System.out.println(dao);
}
public String save(String json) {
String result = (dao != null ? dao.toString() : "null");
return result;
}
}
To generate the WSDL I am using the Eclipse resource new -> other -> Web Service. The Service Implementation is set to Start service and the Client type is set to No client. I am setting Style and use to document/literal.
I have the the WebContent/WEB-INF/bean.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
I have the WebContent/META-INF/context.xml empty
My pom.xml is this:
<!-- CDI -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>2.2.14.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>
<version>2.2.14.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>2.2.14.Final</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>1.2.2.Final</version>
</dependency>