【问题标题】:Send JMS from Jboss 4.2.3GA to 7.1.1从 Jboss 4.2.3GA 发送 JMS 到 7.1.1
【发布时间】:2014-09-30 20:23:03
【问题描述】:

我正在尝试将 JMS 消息(远程)从 Jboss 4.2.3GA 实例发送到 Jboss 7.1.1.Final 实例。当我尝试“7.1.1 风格”时

properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "remote://127.0.0.1:4447");
InitialContext jndiContext = new InitialContext(properties);
ConnectionFactory cf = (ConnectionFactory) jndiContext.lookup("jms/RemoteConnectionFactory");

我明白了

ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory

当我尝试以“4.2.3”方式进行时

properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "remote://127.0.0.1:4447");
InitialContext jndiContext = new InitialContext(properties);
ConnectionFactory cf = (ConnectionFactory) jndiContext.lookup("jms/RemoteConnectionFactory");

我明白了

UnknownHostException:远程

地址不同(jnp://127.0.0.1:4447)我有java.io.StreamCorruptedException: invalid stream header: 0000000C

我从 standalone.bat --server-config=standalone-full.xml -b 0.0.0.0 开始 7.1.1。 请帮忙,因为我在这里蒙着眼睛。任何有关如何将 JMS 从 4.2.3GA 发送到 7.1.1 的示例将不胜感激。

【问题讨论】:

    标签: jakarta-ee jboss jms jndi


    【解决方案1】:

    这个问题的主要问题在于

    不再支持以前 JBoss 版本中使用的基于 jnp 的旧 JNDI 实现

    我们必须使用remote: 协议。有用的资源是jboss dev guide JNDImaster the jboss ejb tutorial

    他们告诉你,你需要来自%JBOSS_HOME%/bin/clientjboss-client.jar。 Java SE 项目确实如此。对于不同的应用程序服务器,它会导致一些javax.* 冲突并导致我的注入点失败。我最终得到了这组罐子:

    • jboss-remoting-3.2.3.GA.jar
    • jboss-remote-naming-1.0.2.Final.jar
    • jboss-sasl-1.0.0.Final.jar
    • jboss-marshalling-1.3.11.GA.jar
    • jboss-marshalling-river-1.3.11.GA.jar
    • jboss-logging-3.1.0.GA.jar
    • netty-3.2.6.Final.jar
    • xnio-api-3.0.3.GA.jar
    • xnio-nio-3.0.3.GA.jar
    • hornetq-core-client-2.2.13.Final.jar
    • hornetq-jms-client-2.2.13.Final.jar

    并成功向Jboss 7.1.1测试主题发送消息:

    final Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
    env.put(Context.PROVIDER_URL, "remote://127.0.0.1:4447");
    InitialContext jndiContext = new InitialContext(env);
    ConnectionFactory cf = (ConnectionFactory) jndiContext.lookup("jms/RemoteConnectionFactory");
    Topic topic = (Topic) jndiContext.lookup("jms/topic/test");
    Connection conn = null;
    try {
        conn = cf.createConnection();
        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(topic);
        TextMessage message = session.createTextMessage("Hello world");
        producer.send(message);
    } catch (JMSException e) {
        log.error(e);
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (JMSException e) {
                log.error(e);
            }
        }
    }
    

    但是我不得不关闭安全性,因为

    javax.security.sasl.SaslException:身份验证失败:所有可用的身份验证机制都失败

    我不知道如何进行身份验证。我使用add-user 脚本添加用户并使用不同的属性但没有成功。您可以通过在 standalone-full.xml 的此部分中删除 security-realm="ApplicationRealm" 来关闭安全性

    <subsystem xmlns="urn:jboss:domain:remoting:1.1">
        <connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
    </subsystem>
    

    并取消选择配置文件>消息>消息提供程序>启用安全性?在 Jboss 服务器管理控制台中。

    更新 没有必要禁用安全性。使用此选项:

    env.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
    env.put(Context.SECURITY_PRINCIPAL, "username");
    env.put(Context.SECURITY_CREDENTIALS, "pass");
    

    【讨论】:

      猜你喜欢
      • 2017-07-06
      • 2016-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-18
      • 1970-01-01
      • 2012-04-30
      • 2013-10-19
      相关资源
      最近更新 更多