javaspring-bootjms

Trying to send a message to a queue on weblogic


I have a spring boot application that is deployed on a WebLogic server, on that server there is a JmsModule defined that I need to use to send messages.

I have the following as my sending class:

@Component
public class JmsMessageSender {
    @Value("${spring.jms.queue}")
    private String jmsQueue;

    public JmsMessageSender(ConnectionFactory connectionFactory) {
        this.jmsTemplate = new JmsTemplate(connectionFactory);
    }

    public void send(Message message) {
        jmsTemplate.convertAndSend(jmsQueue, message.getBody(), mess -> {
            log.info("setting standard JMS headers before sending");
            mess.setJMSMessageID(determineMessageId(message));
            return mess;
        });
    }
...

The queue has a JNDI name and is retrieved via spring properties, it's defined as:

spring:
  jms:
    jndi-name: jms/ConnectionFactory
    queue: jms/ProcessEventQueue

When starting the application I see no errors' in the log but when I try to access this piece of code the following error is shown:

2022-06-30T10:22:20,072 [ERROR] org.springframework.boot.web.servlet.support.ErrorPageFilter ([ACTIVE] ExecuteThread: '19' for queue: 'weblogic.kernel.Default (self-tuning)') - Forwarding to error page from request [/ha] due to exception [Uncategorized exception occurred during JMS processing; nested exception is weblogic.jms.common.JMSException: [JMSExceptions:045103]While trying to find a topic or a queue, the specific JMS server requested could not be found. The linked exception may contain more information about the reason for failure.]
org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is weblogic.jms.common.JMSException: [JMSExceptions:045103]While trying to find a topic or a queue, the specific JMS server requested could not be found. The linked exception may contain more information about the reason for failure.
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:311) ~[spring-jms-5.3.20.jar:5.3.20]
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:185) ~[spring-jms-5.3.20.jar:5.3.20]
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:507) ~[spring-jms-5.3.20.jar:5.3.20]
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:584) ~[spring-jms-5.3.20.jar:5.3.20]
    at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:691) ~[spring-jms-5.3.20.jar:5.3.20]
...
Caused by: javax.naming.NameNotFoundException: Unable to resolve 'weblogic.jms.backend.jms'. Resolved 'weblogic.jms.backend'
    at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1292) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:354) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:227) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:532) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:228) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:532) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:228) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:532) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:228) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:532) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.RootNamingNode.lookup(RootNamingNode.java:84) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:307) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:435) ~[com.oracle.weblogic.jndi.jar:12.2.1.4]
    at weblogic.jms.frontend.FEManager.destinationCreate(FEManager.java:300) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.jms.frontend.FEManager.invoke(FEManager.java:588) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:1015) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.messaging.dispatcher.DispatcherImpl.syncRequest(DispatcherImpl.java:256) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncNoTran(DispatcherImpl.java:359) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:67) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.messaging.dispatcher.CrossPartitionDispatcher.dispatchSyncNoTran(CrossPartitionDispatcher.java:64) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.jms.client.JMSSession.createDestination(JMSSession.java:3460) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.jms.client.JMSSession.createQueue(JMSSession.java:2749) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at weblogic.jms.client.WLSessionImpl.createQueue(WLSessionImpl.java:945) ~[com.oracle.weblogic.jms.jar:12.2.1.4]
    at org.springframework.jms.support.destination.DynamicDestinationResolver.resolveQueue(DynamicDestinationResolver.java:85) ~[spring-jms-5.3.20.jar:5.3.20]
    at org.springframework.jms.support.destination.DynamicDestinationResolver.resolveDestinationName(DynamicDestinationResolver.java:59) ~[spring-jms-5.3.20.jar:5.3.20]
    at org.springframework.jms.support.destination.JmsDestinationAccessor.resolveDestinationName(JmsDestinationAccessor.java:115) ~[spring-jms-5.3.20.jar:5.3.20]
    at org.springframework.jms.core.JmsTemplate.lambda$send$3(JmsTemplate.java:585) ~[spring-jms-5.3.20.jar:5.3.20]
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:504) ~[spring-jms-5.3.20.jar:5.3.20]

I have verified that the correct property is retrieved and that it matches the JNDI name of the JmsModule in WebLogic. The web.xml and weblogic.xml are standard and do not contain anything related to JMS. Is there something that I'm doing wrong/is missing?


Solution

  • I have found the solution. This is a case where WebLogic does not return a ConnectionFactory that can be used to create a JmsTemplate in order to interact with JmsQueue's.

    The solution is to not create a JmsTemplate from a supplied ConnectionFactory but to directly refer to a JmsTemplate.

    @Component
    public class JmsMessageSender {
    
        @Resource
        private JmsTemplate jmsTemplate;
    
        public JmsMessageSender() {
            ...
        }
        ...