JBoss Community

Wrong warning detection for CDI injection point

created by Grégoire Rolland in JBoss Tools - View the full discussion

Hi,

 

I realize the Weld Example for injecting SLF4J Logger with Eclipse, Maven and Jboss Tools.

I build one project where there is the bean with the producer method for Logger :

 

Project 1

   --> LoggerFactory

    --> Log Annotation

 

And I create a second project wich depend from the first :

 

Project 2

    --> BeanWithLogger

 

I write this code :

 

Log.java

{code}

@BindingType

@Retention(RetentionPolicy.RUNTIME)

@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER })

public @interface Log

{

}

{code}

LoggerFactory.java

{code}

@Named

public class LoggerFactory

{

    @Produces

    @Log

    public Logger createLogger(final InjectionPoint in_injectionPoint)

    {

        return org.slf4j.LoggerFactory.getLogger(in_injectionPoint.getMember().getDeclaringClass());

    }

}

{code}

BeanWithLogger.java

{code}

@Named

public class BeanWithLogger

{

    @Inject

    @Log // Here CDI validiator says : No bean is eligible for injection to the injection point [JSR-299 §5.2.1]

    private Logger logger = null;

}

{code}

I think this warning is wrong. The code works fine. Is there a problem (misconfuguration or bug) with the CDI validator ?

 

Thanks for your answers

Reply to this message by going to Community

Start a new discussion in JBoss Tools at Community