JBOSS 5.1 升级 - 消息传递问题

发布于 2024-09-10 00:34:56 字数 4641 浏览 6 评论 0原文

我正在尝试在 JBOSS 5.1 中启动一个 hello world MDB,看看如何将我们的消息传递应用程序引入 JBOSS 5.1 消息传递中。简单的hello world MDB 给了我一个有线问题。 MDB 部署良好,启动 JBOSS 5.1 AS 时没有问题。然而,当我尝试从也运行 JBOSS 51 的客户端发送消息时,抛出以下异常,

09:03:24,790 ERROR [STDERR] java.lang.NullPointerException
09:03:24,790 ERROR [STDERR]     at org.jboss.jms.client.container.FailoverValveInterceptor.invoke(FailoverValveInterceptor.java:87)
09:03:24,790 ERROR [STDERR]     at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
09:03:24,791 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
09:03:24,791 ERROR [STDERR]     at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
09:03:24,791 ERROR [STDERR]     at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
09:03:24,791 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
09:03:24,791 ERROR [STDERR]     at org.jboss.jms.client.delegate.ClientConnectionDelegate.createSessionDelegate(ClientConnectionDelegate.java)
09:03:24,791 ERROR [STDERR]     at org.jboss.jms.client.JBossConnection.createSessionInternal(JBossConnection.java:269)
09:03:24,791 ERROR [STDERR]     at org.jboss.jms.client.JBossConnection.createQueueSession(JBossConnection.java:165)

但是当我尝试从独立的 JAVA 程序连接时,消息传递工作正常。我不知道我现在应该做什么。以下是配置,

ejb-jar.xml:

<message-driven>
      <ejb-name>HelloWorldMDB</ejb-name>
      <ejb-class>com.yodlee.messaging.mdbs.HelloWorldMDB</ejb-class>
      <transaction-type>Container</transaction-type>
      <message-driven-destination>
        <destination-type>javax.jms.Queue</destination-type>
        <subscription-durability>Durable</subscription-durability></message-driven-destination>
      <resource-ref>
        <res-ref-name>HelloWorldMDB</res-ref-name>
        <res-type>javax.jms.QueueConnectionFactory</res-type>
        <res-auth>Container</res-auth></resource-ref> 
</message-driven>

jboss.xml:

<message-driven>
                <ejb-name>HelloWorldMDB</ejb-name>
                <destination-jndi-name>queue/HelloWorldQueue</destination-jndi-name>
                <mdb-user>mqm</mdb-user>
                <mdb-passwd>mqm</mdb-passwd>
                <resource-ref>
                        <res-ref-name>HelloWorldMDB</res-ref-name>
                        <jndi-name>MDBDLQCF</jndi-name>
                </resource-ref>
</message-driven>

我在servlt和独立程序中使用它的客户端代码与下面完全相同,

Properties env = new Properties();

        String queueName = "queue/HelloWorldQueue";
        String CFname = "ConnectionFactory";

        env.put(Context.PROVIDER_URL, "jnp://....:1099");
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.jnp.interfaces.NamingContextFactory");
        env
                .put(Context.URL_PKG_PREFIXES,
                        "org.jboss.naming:org.jnp.interfaces");

        try {
            InitialContext ctx = new InitialContext(env);

            System.out.println("Looking up for queue");
            System.out.println(ctx.lookup(queueName).getClass().getName());
            Queue destination = (Queue) ctx.lookup(queueName);

            System.out.println(destination.getQueueName());

            System.out.println("Looking up for connection factory");
            System.out.println(ctx.lookup(CFname).getClass().getName());
            QueueConnectionFactory qcf = (QueueConnectionFactory)ctx.lookup(CFname);

            System.out.println("getting connection");
            QueueConnection conn = qcf.createQueueConnection("abc", "abc");
            System.out.println("creating session");
            QueueSession queueSession = conn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);


            QueueSender sender = queueSession.createSender(destination);

            TextMessage message = queueSession.createTextMessage();

            message.setText("Test Message");

            System.out.println("Sending Message...");

            sender.send(message);
            System.out.println("Finished Sending Message.");

            sender.close();
            conn.close();
            queueSession.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
        }

你能帮我解决这个问题吗?您还需要其他信息来调试吗?

I'm trying bring up a hello world MDB in JBOSS 5.1 to see how i can get our messaging application into JBOSS 5.1 Messaging. The simple hellow world MDB gives me a wired issue. The MDB deployed fine and no problem in starting the JBOSS 5.1 AS. However when i tried to send a message from a client which is also running JBOSS 51 is throwing the following exception,

09:03:24,790 ERROR [STDERR] java.lang.NullPointerException
09:03:24,790 ERROR [STDERR]     at org.jboss.jms.client.container.FailoverValveInterceptor.invoke(FailoverValveInterceptor.java:87)
09:03:24,790 ERROR [STDERR]     at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
09:03:24,791 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
09:03:24,791 ERROR [STDERR]     at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
09:03:24,791 ERROR [STDERR]     at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
09:03:24,791 ERROR [STDERR]     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
09:03:24,791 ERROR [STDERR]     at org.jboss.jms.client.delegate.ClientConnectionDelegate.createSessionDelegate(ClientConnectionDelegate.java)
09:03:24,791 ERROR [STDERR]     at org.jboss.jms.client.JBossConnection.createSessionInternal(JBossConnection.java:269)
09:03:24,791 ERROR [STDERR]     at org.jboss.jms.client.JBossConnection.createQueueSession(JBossConnection.java:165)

However when i try to connect from a standalone JAVA program the messaging works fine. I have no clue on what i should do now. The following are the configuration,

ejb-jar.xml:

<message-driven>
      <ejb-name>HelloWorldMDB</ejb-name>
      <ejb-class>com.yodlee.messaging.mdbs.HelloWorldMDB</ejb-class>
      <transaction-type>Container</transaction-type>
      <message-driven-destination>
        <destination-type>javax.jms.Queue</destination-type>
        <subscription-durability>Durable</subscription-durability></message-driven-destination>
      <resource-ref>
        <res-ref-name>HelloWorldMDB</res-ref-name>
        <res-type>javax.jms.QueueConnectionFactory</res-type>
        <res-auth>Container</res-auth></resource-ref> 
</message-driven>

jboss.xml:

<message-driven>
                <ejb-name>HelloWorldMDB</ejb-name>
                <destination-jndi-name>queue/HelloWorldQueue</destination-jndi-name>
                <mdb-user>mqm</mdb-user>
                <mdb-passwd>mqm</mdb-passwd>
                <resource-ref>
                        <res-ref-name>HelloWorldMDB</res-ref-name>
                        <jndi-name>MDBDLQCF</jndi-name>
                </resource-ref>
</message-driven>

The client code which i use it in servelt and stand alone program is exactly same like below,

Properties env = new Properties();

        String queueName = "queue/HelloWorldQueue";
        String CFname = "ConnectionFactory";

        env.put(Context.PROVIDER_URL, "jnp://....:1099");
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.jnp.interfaces.NamingContextFactory");
        env
                .put(Context.URL_PKG_PREFIXES,
                        "org.jboss.naming:org.jnp.interfaces");

        try {
            InitialContext ctx = new InitialContext(env);

            System.out.println("Looking up for queue");
            System.out.println(ctx.lookup(queueName).getClass().getName());
            Queue destination = (Queue) ctx.lookup(queueName);

            System.out.println(destination.getQueueName());

            System.out.println("Looking up for connection factory");
            System.out.println(ctx.lookup(CFname).getClass().getName());
            QueueConnectionFactory qcf = (QueueConnectionFactory)ctx.lookup(CFname);

            System.out.println("getting connection");
            QueueConnection conn = qcf.createQueueConnection("abc", "abc");
            System.out.println("creating session");
            QueueSession queueSession = conn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);


            QueueSender sender = queueSession.createSender(destination);

            TextMessage message = queueSession.createTextMessage();

            message.setText("Test Message");

            System.out.println("Sending Message...");

            sender.send(message);
            System.out.println("Finished Sending Message.");

            sender.close();
            conn.close();
            queueSession.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
        }

Can you help me fixing this problem? Do you need any other information to debug?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒浓于脸红 2024-09-17 00:34:57

您是从 Servlet 调用这个吗?如果是这样:
您的 WEB-INF/lib 文件夹中的 jar 包有误。
对于 5.0,您需要...
将 javassist.jar 和 jboss-aop-jdk50.jar 放在我的 WEB-INF/lib 文件夹中以使其工作

另请注意:在代码中以反向获取顺序关闭资源,并在 finally 块中执行此操作。

Are you calling this from a Servlet ? If so:
You have the wrong jars in your WEB-INF/lib folder.
For 5.0 you needed ...
put the javassist.jar and jboss-aop-jdk50.jar in my WEB-INF/lib folder to make it work

On another note: In your code close your resources in reverse acquisition order and also do it in a finally block.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文