I'm facing a problem with JBoss AS7 / JEE 6 while using a producer for a logger that work's fine with WildFly and JEE 7.
I've created a qualifier:
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface BpeLogger {
}
A producer class:
public class LoggerProducer{
@Produces
@BpeLogger
public Logger produceLogger(InjectionPoint injectionPoint) {
return LoggerFactory.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
}
And now I'm trying to inject the logger in another CDI Bean with:
@Inject
@BpeLogger
private Logger logger;
Deploying fails with following exception:
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Logger] with qualifiers [@BpeLogger] at injection point [[field] @Inject @BpeLogger private de.ulc.bpe.web.process.Domino.logger]
What's wrong here?
Make sure there is a beans.xml file in the META-INF folder.
You can also try to annotate your LoggerProducer class as a CDI bean directly. E.g. add @Named annotation and possibly a suitable scope. In your case, @Singleton would probably do just fine.