views:

43

answers:

1

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?

A: 

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.

Romain Hippeau
Yes. I'm calling from servlet and it doesn't work for me. If i create the above code in JAVA program it works perfectly fine. On the other hand when i call from servlet i see the following WARNING message in server after some time.WARN [SimpleConnectionManager] A problem has been detected with the connection to remote client
Btw, I'm using JBOSS 5.1 and my servlet program don't have anything in the WEB-INF/lib folder.
@mmuthu - Just for grins add the same jars into the WEB-INF/lib that you had in the standalone program. fix your connection issue first.
Romain Hippeau
I tried coping JAR's and even upgraded the JBOSS Messaging to 1.4.6 GA version. I'm getting the same exception