I am trying to write annotations to inject JMS resources. Here is my code
public class JMSResourceProducer {
private static final String WL_INIT_CONN_FACTORY ="weblogic.jndi.WLInitialContextFactory";
private String WL_SERVER_URL = "URL";
private String QF ="QFNAME";
private String QQ ="QNAME";
public InitialContext createInitialContext() throws NamingException {
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY, WL_INIT_CONN_FACTORY);
properties.put(Context.PROVIDER_URL, WL_SERVER_URL);
return new InitialContext(properties);
}
@Produces @Image2000
public QueueSession createQueueSession () throws NamingException, JMSException {
InitialContext initialContext = createInitialContext();
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup(QF);
QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
return queueConnection.createQueueSession(true, 0);
}
@Produces @Image2000
public Queue createQueue ( ) throws NamingException {
InitialContext initialContext = createInitialContext();
Queue queue = (Queue)initialContext.lookup(QQ);
return queue;
}
}
And this is how I use it in my class
@Inject @Image2000
private QueueSession queueSession;
@Inject @Image2000
private Queue jmsQueue;
My annotation
@Qualifier
@Target({TYPE, METHOD, PARAMETER, FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Image2000 {
}
But I am getting below error when my Wildfly starts..
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type QueueSession with qualifiers @Image2000
at injection point [UnbackedAnnotatedField] @Inject @Image2000 .queueSession
Any clue whats wrong with my producer class ?
Depending on the discovery mode defined in beans.xml, you may need to annotate JMSResourceProducer with a bean defining annotation (Dependent, ApplicationScoped or another better suited).