CDI injected JMS topic is not working
Issue
-
I am unable to inject JMS topic, and want to find out why it does not work.
-
ResourceProducer.java :
@Produces
@Resource(lookup="topic/eventtopic")
private Topic eventTopic;
- JmsSubscriber.java :
@Inject
private Topic topic;
public void start(){
try {
connection = connectionFactory.createConnection();
connection.setExceptionListener(this);
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(topic);
consumer.setMessageListener(this);
connection.start();
} catch (JMSException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
}
}
- I got javax.jms.InvalidDestinationException: "Not a HornetQDestination:HornetQTopic" when I ran the code above. But if I use JNDI lookup, it was working fine.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.3.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
