i want to use a producer in my application but i'm stuck at the point, where i'm trying to inject the bean. im getting the famous WELD-001409 error. please lighten up my understanding of cdi producer.
here's my interface:
@Named
public interface MessageSender {
void sendMessage();
}
the bean:
public class EmailMessageSender implements MessageSender {
@Override
public void sendMessage() {
System.out.println("Sending email message");
}
}
and the producer:
@SessionScoped
public class MessageSenderFactory implements Serializable {
private static final long serialVersionUID = 5269302440619391616L;
@Produces
public MessageSender getMessageSender() {
return new EmailMessageSender();
}
}
now i'm injecting the bean:
@Inject
MessageSender messageSender;
when i'm trying to deploy the project i get the WELD-001409 error and eclipse also is saying that there are multiple injection points.
it works with explicit naming:
@Inject @Named("messageSender")
MessageSender messageSender;
is this naming neccessary?