在JNDI中找不到WAS-8.5和ActiveMQ集成错误ConnectionFactory

时间:2019-05-17 07:09:28

标签: jms activemq websphere-8

我正在使用ActiveMQ在WAS 8.5中创建JMS提供程序,但是将消息发送到队列时出现错误。

  

javax.resource.spi.ResourceAllocationException:在JNDI中找不到ConnectionFactory

我根据以下答案创建了连接工厂和队列:

ActiveMQ 5.11 with WebSphere Application Server 8.5

当我直接向ActiveMQ发送消息时,它将使我的消息入队。

    InitialContext initialContext = null;
    QueueConnectionFactory queueConnectionFactory = null;
    QueueConnection queueConnection = null;
    QueueSession queueSession = null;
    Queue queue = null;
    QueueReceiver queueReceiver = null;
    QueueSender queueSender = null;
    String queueCF = "jms/ActiveMQCF";
    String queueName = "queue/ActiveMQueue";
    String message = "testJMS3";
    TextMessage textMessage = null;
    String messageID = null;
    try {
        initialContext = new InitialContext();
        queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup(queueCF);
        queueConnection = queueConnectionFactory.createQueueConnection();
        queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        queue = (Queue) initialContext.lookup(queueName);
        queueSender = queueSession.createSender(queue);
        textMessage = queueSession.createTextMessage();
        textMessage.setText(message);
        queueSender.send(textMessage);
        messageID = textMessage.getJMSMessageID();
    } catch (Exception e) {
        e.printStackTrace();
        return e.getMessage();
    }
  

com.ibm.ejs.jms.JMSCMUtils.mapToJMSException(JMSCMUtils.java:140),   com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle.createQueueConnection(JMSQueueConnectionFactoryHandle.java:91),   com.test.AddressBook.testJMS3(AddressBook.java:159),   sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法),   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90),   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55),   java.lang.reflect.Method.invoke(Method.java:508),   org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63),   org.apache.wink.server.handlers.AbstractHandler.handleRequest(AbstractHandler.java:33),   org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26),   org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22),   org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:75),   org.apache.wink.server.internal.handlers.CreateInvocationParametersHandler.handleRequest(CreateInvocationParametersHandler.java:54)

0 个答案:

没有答案