简体   繁体   English

在 JBoss EAP 7 上部署 JMS 应用程序时出错

[英]Error deploying JMS appplication on JBoss EAP 7

I receive the following error when the application is deployed:部署应用程序时收到以下错误:

/opt/eap/bin # cat ../standalone/deployments/SitioWebFinal.war.failed { "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.java:env.jms.fabrica"], "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.SitioWebFinal.SitioWebFinal.env.jms.fabrica is missing [jboss.naming.context.java.jboss.java:env.jms.fabrica]"]

I have the following code where send the messages to a amq server:我有以下代码将消息发送到 amq 服务器:

package amqlib;

import javax.naming.*;
import javax.jms.*;

public class Producctor {
    public void enviaMensajeCola(String mundo) throws JMSException {
        try { 
            InitialContext initCtx = new InitialContext();

            QueueConnectionFactory f = (QueueConnectionFactory) initCtx.lookup("java:jboss/exported/jms/fabrica");
            QueueConnection con = f.createQueueConnection();
            con.start();

            QueueSession ses = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

            InitialContext initCtx2 = new InitialContext();
            Queue t = (Queue) initCtx2.lookup("/queue");

            QueueSender sender = ses.createSender(t);

            TextMessage msg = ses.createTextMessage();

            InputStreamReader(System.in));

            String s = mundo;
            msg.setText(s);
            // 7) send message

            sender.send(msg);

            System.out.println("Message successfully sent.");

            // 8) connection close

            con.close();

        }

        catch (Exception e) {
            System.out.println("Este es el error " + e);
        }
    }

    public static void main(String[] args) throws JMSException {
        Producctor p = new Producctor();
        p.enviaMensajeCola("Hola Mundo");

    }
}

And this is the of the conection factory in standalone-full-ha.xml configuraton file.这是standalone-full-ha.xml配置文件中的连接工厂。

<connection-factory name="fabrica" entries="java:jboss/exported/jms/fabrica" connectors="in-vm"/>

This is the web.xml inside the.war this is the same xml I use in tomcat 9. I dont if it can be the seme file. This is the web.xml inside the.war this is the same xml I use in tomcat 9. I dont if it can be the seme file.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>SitioWebFinal</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

      <distributable/>

  <resource-ref>
    <description>ConnectionFactory</description>
    <res-ref-name>jms/fabrica</res-ref-name>
    <res-type>org.apache.activemq.ActiveMQConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    <lookup-name>java:env/jms/fabrica</lookup-name>
  </resource-ref>
</web-app>

I have the context.xml as well我也有上下文。xml

<?xml version="1.0" encoding="UTF-8"?>
<Context name="/SitioWebFinal" antiJARLocking="true">
        <Resource
            name="jms/fabrica"
            auth="Container"
            type="org.apache.activemq.ActiveMQConnectionFactory"
            description="JMS Connection Factory"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            brokerURL="tcp://amq-cicd-int-amq-tcp.svc.cluster.local:61616"
            brokerName="ActiveMQBroker"
            useEmbeddedBroker="false"/>

        <Resource name="jms/topic"
            auth="Container"
            type="org.apache.activemq.command.ActiveMQTopic"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            physicalName="APP.JMS.TOPIC"/>
        <Resource name="jms/queue"
            auth="Container"
            type="org.apache.activemq.command.ActiveMQQueue"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            physicalName="APP.JMS.QUEUE"/>  
</Context>

Regards问候

Your connection-factory configuration doesn't make a lot of sense.您的connection-factory配置没有多大意义。 Here's what you're using:这是您正在使用的内容:

<connection-factory name="fabrica" entries="java:jboss/exported/jms/fabrica" connectors="in-vm"/>

You're using the exported JNDI namespace which exposes this connection factory to clients running outside the JVM (ie remote clients), but you're using in-vm for the connectors which means clients running outside the JVM won't actually be able to use the connection factory since the in-vm connector won't work for them.您正在使用exported的 JNDI 命名空间,该名称空间将此连接工厂暴露给在 JVM 之外运行的客户端(即远程客户端),但您使用in-vm作为connectors ,这意味着在 JVM 之外运行的客户端实际上无法使用连接工厂,因为in-vm连接器不适用于他们。

Try simply modifying the existing InVmConnectionFactory for your clients running in the application server, eg:尝试简单地为在应用程序服务器中运行的客户端修改现有的InVmConnectionFactory ,例如:

<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory java:/jms/fabrica" connectors="in-vm"/>

Then try modifying the existing RemoteConnectionFactory for your remote clients, eg:然后尝试为您的远程客户端修改现有的RemoteConnectionFactory ,例如:

<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory java:jboss/exported/jms/fabrica" connectors="http-connector"/>

Once you've made those changes redeploy your application.完成这些更改后,重新部署您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM