4 Replies Latest reply on Jul 18, 2010 10:37 PM by gaohoward

    JBOSS Messaging Issue

    mmuthu

      I'm trying to bring up my 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 (servlet) which is also running in different JBOSS instance is always throwing the following exception while creating a session.

       

      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? I'm using JBOSS Messaging 1.4.6 GA version.

        • 1. Re: JBOSS Messaging Issue
          gaohoward

          JBM 1.4.6 comes with a mdb example, you can try it and see if you can make the example work first.

           

          The example can be downloaded at

           

          http://jboss.org/jbossmessaging/downloads/jbm-examples-1.4.6.zip

          • 2. Re: JBOSS Messaging Issue
            mmuthu

            I tried running JBOSS Messaging examples. It did not help much. So later on i started everything from the scratch and reaized that i need "messaging" folder even in the place where i'm running client application in JBOSS. When i have messaging folder, during sartup i can see the connection factories are created and i believe this resolves my problem. Now my messaging client able to send messages to server.

             

            Is this dependency is right? Do we have any other better way of doing it? I really don't like to have the "messaging" folder in my client application which requires to have "ServerPeer" and some form of JMSUser, Persistency services, etc. I do not want all of them in my client application.

             

            Any suggestion to do achieve this ?

            • 3. Re: JBOSS Messaging Issue
              peterj

              All you need to run a messaging client are the JAR files in the client directory (though just now checking with one of my scripts I see that I also include a few JARs from the lib directory). You actually do not need all of them, a tool such as JBoss Tattletale can help you identify the exact files required.

              • 4. Re: JBOSS Messaging Issue
                gaohoward

                Each example has a readme.html for you. Please read it and you'll find out how to run it. For most non-clustering examples, you just need to type 'ant'.