我正在嘗試編寫註釋來注入JMS資源。這裏是我的代碼類型QueueSession的CDI-不滿意的依賴關係
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;
}
}
這是我如何使用它在我的課
@Inject @Image2000
private QueueSession queueSession;
@Inject @Image2000
private Queue jmsQueue;
我的註釋
@Qualifier
@Target({TYPE, METHOD, PARAMETER, FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Image2000 {
}
但我得到下面的錯誤我Wildfly啓動時..
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type QueueSession with qualifiers @Image2000
注射時點[UnbackedAnnotatedField] @Inject @ Image2000 .queueSession
任何線索什麼是我的生產者類錯?
您可以提供完整的日誌,當Weld容器在'org.jboss.weld'記錄器的'DEBUG'級別引導? JMSResourceProducer, – 2015-03-19 09:39:13
,似乎不是一個bean。使用'@Stateless'或'@ApplicationScope'對它進行註釋 – maress 2015-03-19 15:44:51