my qualifier is :
@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
public @interface JPADAOQ {
}
this is the bean that i want inject
@JPADAOQ
@ApplicationScoped
public class PlotDaoImpl extends JpaDao<Long, Plot> implements PlotDao {
public PlotDaoImpl() {
super(Plot.class);
}
}
finally here is where i want my bean to be injected
@ManagedBean
@SessionScoped
public class PlotController {
@Inject @JPADAOQ
private PlotDaoImpl plotDaoImpl;
@PostConstruct
public void init() {
if (plotDaoImpl==null) {
System.out.println("plotDaoImpl null");
} else {
System.out.println("plotDaoImpl not null");
}
}
But i always got it null so i can't use it.
My configuration :
1.beans.xml
<?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>
2.pom.xml based on wildfly quickstart form here.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>${version.jboss.spec.javaee.7.0}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
I can't figure out why my bean is not injected int @PostConstruct method.