1
votes

I have a webapp which uses a JMS queue, and this worked fine on Wildfly 8.2. But on Wildfly 9.0 I am getting naming exceptions.

As per the example in the guide: https://docs.jboss.org/author/display/WFLY9/Messaging+configuration

A local client could look it up using "java:jboss/exported/jms/queue/test", "java:jms/queue/test", or more simply "jms/queue/test":

standalone.xml:

<subsystem xmlns="urn:jboss:domain:messaging:2.0">
   <hornetq-server>
      [...]
      <jms-destinations>
         <jms-queue name="testQueue">
             <entry name="jms/queue/test"/>
             <entry name="java:jboss/exported/jms/queue/test"/>
         </jms-queue>
      </jms-destinations>
   </hornetq-server>
</subsystem>

Java class:

@Inject
private JMSContext context;

@Resource(lookup="java:jboss/exported/jms/queue/test")
private Destination queueDestination;

...
private void foo() {
        JMSConsumer consumer = context.createConsumer(queueDestination);
}

After I upgraded to Wildfly to 9.0 Final, I get the following exception on context.createConsumer:

 java.lang.RuntimeException: javax.naming.NameNotFoundException: DefaultJMSConnectionFactory -- service jboss.naming.context.java.module.AAA.AAA.DefaultJMSConnectionFactory

I tried changing the @Resource lookup to "java:jms/queue/test" or "jms/queue/test"

nothing seems to work.

Thanks

1

1 Answers

3
votes

You must define a default connection factory as per JavaEE7 spec. http://www.oracle.com/technetwork/articles/java/jms20-1947669.html

<pooled-connection-factory name="hornetq-ra">
<transaction mode="xa"/>
<connectors>
    <connector-ref connector-name="in-vm"/>
</connectors>
<entries>
    <entry name="java:/JmsXA"/>
    <!-- Global JNDI entry used to provide a default JMS Connection factory to EE application -->
    <entry name="java:jboss/DefaultJMSConnectionFactory"/>
</entries>

and set the default bindings:

<default-bindings jms-connection-factory="java:jboss/DefaultJMSConnectionFactory" ...."/>

If you want to use a specific connection factory then you must use JMSConnectionFactory. In absence of this annotation, a default connection factory is used.

@Inject
@JMSConnectionFactory("jms/customConnFactory")
JMSContext ctx;