Search code examples
jakarta-eeglassfishjmsjava-ee-7

JNDI lookup on client fails for JMS resource


I'm about to lose my mind trying to make a simple program from a JMS tutorial work properly. The source code from the tutorial is here (ignore the samples folder), but it's not organized properly (the dependency for the MDB project must be included in the SE project and other small bits). As you can see, the program consists of an EJB module containing an MDB to be deployed on an application server (I'm using Glassfish 5) and two Java SE clients, both having a main method.

After creating and configuring the JMS resources for a ConnectionFactory and a Topic, the MDB module is deployed flawlessly (if the resource has a different JNDI name than the one specified on the MDB or doesn't exist at all, the deployment fails). However, when I try to start any of the two clients, using the same JNDI names, the following exception occurs:

Aug 30, 2019 7:33:01 AM com.sun.enterprise.connectors.ActiveRAFactory createActiveResourceAdapter
SEVERE: RAR6001 : Class Not found : com.sun.messaging.jms.ra.ResourceAdapter
Aug 30, 2019 7:33:01 AM com.sun.enterprise.connectors.ActiveRAFactory createActiveResourceAdapter
SEVERE:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Error in creating active RAR
        at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter(ActiveRAFactory.java:87)
        at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:188)
        at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter(ConnectorRuntime.java:403)
        at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance(ConnectorObjectFactory.java:83)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
        at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:503)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:463)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:414)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at store.OrderProducer.main(OrderProducer.java:21)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.sun.messaging.jms.ra.ResourceAdapter
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter(ActiveRAFactory.java:79)
        ... 15 more

[WARNING]
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
Caused by: javax.naming.NamingException: Lookup failed for 'jms/javaee7/ConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:467)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:414)
    at javax.naming.InitialContext.lookup (InitialContext.java:417)
    at store.OrderProducer.main (OrderProducer.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
Caused by: javax.naming.NamingException: Failed to look up ConnectorDescriptor from JNDI
    at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance (ConnectorObjectFactory.java:90)
    at javax.naming.spi.NamingManager.getObjectInstance (NamingManager.java:321)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance (SerialContext.java:503)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:463)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:414)
    at javax.naming.InitialContext.lookup (InitialContext.java:417)
    at store.OrderProducer.main (OrderProducer.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Error in creating active RAR
    at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter (ActiveRAFactory.java:87)
    at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter (ResourceAdapterAdminServiceImpl.java:188)
    at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter (ConnectorRuntime.java:403)
    at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance (ConnectorObjectFactory.java:83)
    at javax.naming.spi.NamingManager.getObjectInstance (NamingManager.java:321)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance (SerialContext.java:503)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:463)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:414)
    at javax.naming.InitialContext.lookup (InitialContext.java:417)
    at store.OrderProducer.main (OrderProducer.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.sun.messaging.jms.ra.ResourceAdapter
    at java.net.URLClassLoader.findClass (URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
    at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter (ActiveRAFactory.java:79)
    at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter (ResourceAdapterAdminServiceImpl.java:188)
    at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter (ConnectorRuntime.java:403)
    at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance (ConnectorObjectFactory.java:83)
    at javax.naming.spi.NamingManager.getObjectInstance (NamingManager.java:321)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance (SerialContext.java:503)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:463)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:414)
    at javax.naming.InitialContext.lookup (InitialContext.java:417)
    at store.OrderProducer.main (OrderProducer.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.173 s
[INFO] Finished at: 2019-08-30T07:33:02+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project store-se: An exception occured while executing the Java class. null: InvocationTargetException: Lookup failed for 'jms/javaee7/ConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}: Failed to look up ConnectorDescriptor from JNDI: Error in creating active RAR: com.sun.messaging.jms.ra.ResourceAdapter -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project store-se: An exception occured while executing the Java class. null
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. null
    at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:352)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
Caused by: javax.naming.NamingException: Lookup failed for 'jms/javaee7/ConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:467)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:414)
    at javax.naming.InitialContext.lookup (InitialContext.java:417)
    at store.OrderProducer.main (OrderProducer.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
Caused by: javax.naming.NamingException: Failed to look up ConnectorDescriptor from JNDI
    at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance (ConnectorObjectFactory.java:90)
    at javax.naming.spi.NamingManager.getObjectInstance (NamingManager.java:321)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance (SerialContext.java:503)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:463)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:414)
    at javax.naming.InitialContext.lookup (InitialContext.java:417)
    at store.OrderProducer.main (OrderProducer.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Error in creating active RAR
    at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter (ActiveRAFactory.java:87)
    at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter (ResourceAdapterAdminServiceImpl.java:188)
    at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter (ConnectorRuntime.java:403)
    at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance (ConnectorObjectFactory.java:83)
    at javax.naming.spi.NamingManager.getObjectInstance (NamingManager.java:321)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance (SerialContext.java:503)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:463)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:414)
    at javax.naming.InitialContext.lookup (InitialContext.java:417)
    at store.OrderProducer.main (OrderProducer.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.sun.messaging.jms.ra.ResourceAdapter
    at java.net.URLClassLoader.findClass (URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
    at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter (ActiveRAFactory.java:79)
    at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter (ResourceAdapterAdminServiceImpl.java:188)
    at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter (ConnectorRuntime.java:403)
    at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance (ConnectorObjectFactory.java:83)
    at javax.naming.spi.NamingManager.getObjectInstance (NamingManager.java:321)
    at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance (SerialContext.java:503)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:463)
    at com.sun.enterprise.naming.impl.SerialContext.lookup (SerialContext.java:414)
    at javax.naming.InitialContext.lookup (InitialContext.java:417)
    at store.OrderProducer.main (OrderProducer.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:748)

Other than GlassFish 5, I tried using both the latest version of the Payara server and GlassFish 4, but the problem persists. Note that I included in the client side SE project the Java EE 7 API dependency and the gf-client 5.1.0 dependency, as well as the dependency for the MDB project. As the stack seems to suggest, the ResourceAdapter class is missing, which is weird since I included the gf-client dependency in the project.

Here's the code for the MDB consumer, which is being deployed just fine (not sure wether it works or not since I can't start the producer on the SE client side):

@MessageDriven(mappedName = "jms/javaee7/Topic", activationConfig = {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "orderAmount > 1000")
})
public class ExpensiveOrderMDB implements MessageListener {

    @Override
    public void onMessage(Message message) {
        try {
            OrderDTO order = message.getBody(OrderDTO.class);
            System.out.println(String
                .format("Expensive order received: %s", order));
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

}

And here's the code for the SE producer and consumer:

public class OrderProducer {

    private static final Float TOTAL_AMOUNT = 2500f;

    public static void main(String[] args) throws NamingException {
        Float totalAmount = OrderProducer.TOTAL_AMOUNT;
        OrderDTO order = 
                new OrderDTO(1234l, new Date(), "Betty Moreau", totalAmount);
        Context jndiContext = new InitialContext();
        ConnectionFactory connectionFactory = (ConnectionFactory)
                jndiContext.lookup("jms/javaee7/ConnectionFactory");
        Destination topic = (Destination) 
                jndiContext.lookup("jms/javaee7/Topic");
        try (JMSContext jmsContext = connectionFactory.createContext()) {
            jmsContext.createProducer()
                    .setProperty("orderAmount", totalAmount)
                    .send(topic, order);
            System.out.println(String.format("Sent order: %s", order));
        }
    }

}
public class OrderConsumer {

    public static void main(String[] args) throws NamingException {
        Context jndiContext = new InitialContext();
        ConnectionFactory connectionFactory = (ConnectionFactory)
                jndiContext.lookup("jms/javaee7/ConnectionFactory");
        Destination topic = (Destination)
                jndiContext.lookup("jms/javaee7/Topic");
        try (JMSContext jmsContext = connectionFactory.createContext()) {
            while (true) {
                OrderDTO order = jmsContext.createConsumer(topic)
                        .receiveBody(OrderDTO.class);
                System.out.println(String.format("Received order: %s", order));
            }
        }
    }

}

I'm sure that the issue is just something silly and easy to fix, but I can't get my head around it. Any help will be deeply appreciated.


Solution

  • I've been able to solve the issue by adding the imqjmsra dependency in the client project AND also upgrading the Java EE API dependency version from 7.0 to 8.0. Edit: realized I could remove the Java EE API depedency since I wasn't actually using it in the project. Kind of weird given that it would cause errors if not upgraded from 7.0 to 8.0.