CDI injected JMS topic is not working

Solution Unverified - Updated -

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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content