ejb@glassfish.java.net

Message Driven Bean

From: Bart de Jonge <bart.de.jonge_at_teamsoft.nl>
Date: Tue, 13 Nov 2007 17:08:21 +0100

Hi,
 
I'm new to java and beans.
I'm using the Eclipse IDE, version Europa.
I've installed Sun Java App Server 9.1.
I've installed the Eclipse plugin for Glassfish V2.
 
First I took on the ejb session bean example.
I managed to make ik work using an AppClient and Java Web Start.
 
Now I'm trying to finish the message driven bean using the Glassfish example
as explained on https://glassfish.dev.java.net/javaee5/ejb/examples/MDB.html
I also did some succesfull configuration of JMS stuff on the server.
 
Deploying of the MDBBean project succeeds
Also the deploying of the EAR (containing the AppClient project and the
MDBBean project) succeeds.
 
But when I run the AppClient with Java Web Start nothing happens.
That is: I cannot find the the system.out.println on the client side
anywhere nor can I find the logger.info strings on the server side (in
server.log).
 
Have you got any hints where to go from here?
 
Thanx in advance for the response.
 
FYI;
The client sidecode looks like this (plse forgive me the unindenting):
 
import javax.annotation.Resource;

import javax.jms.JMSException;

import javax.jms.Queue;

import javax.jms.QueueConnection;

import javax.jms.QueueConnectionFactory;

import javax.jms.QueueSender;

import javax.jms.QueueSession;

import javax.jms.Session;

import javax.jms.TextMessage;

import com.ui.SimpleUI;

public class Main {

    @Resource(mappedName="jms/MDBQueueConnectionFactory")

    private static QueueConnectionFactory queueCF;

    @Resource(mappedName="jms/MDBQueue")

    private static Queue mdbQueue;

    /* (non-Java-doc)

    * @see java.lang.Object#Object()

    */

    public Main() {

        super();

    }

    public static void main(String[] args) {

        QueueConnection queueCon = null;

    try {

        queueCon = queueCF.createQueueConnection();

        QueueSession queueSession = queueCon.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);

        QueueSender queueSender = queueSession.createSender(null);

        TextMessage msg = queueSession.createTextMessage("hallo vanuit de
client");

        queueSender.send(mdbQueue, msg);

    } catch (JMSException e) {

        System.out.println("sendText failed " + e.getLocalizedMessage());

        e.printStackTrace();

    } catch (Exception e) {

        System.out.println("exception.e " + e.getLocalizedMessage());

        e.printStackTrace();

    }

    finally {

        try {

            if (queueCon != null) {

                queueCon.close();

            }

        } catch (JMSException e) {

        }

    }

}


}

 
 
 
The bean class is as follows:
package com.mdbs;

import java.util.logging.Logger;

import javax.ejb.MessageDriven;

import javax.jms.JMSException;

import javax.jms.Message;

import javax.jms.MessageListener;

import javax.jms.TextMessage;

 

@MessageDriven(mappedName="jms/MDBQueue")

public class TestMDB implements MessageListener {

        static final Logger logger = Logger.getLogger("TestMDB");

        public TestMDB() {

            super();

            logger.info("I'm the constructor");

        }

        public void onMessage(Message myMsg) {

            TextMessage txtMsg = (TextMessage)myMsg;

            try {

                logger.info("I'm the message driven bean " +
txtMsg.getText());

            } catch (JMSException e1) {

                logger.warning("jsm exception " + e1.getLocalizedMessage());

                e1.printStackTrace();

            }

        }

}

 
 

Met vriendelijke groet, kind regards,

 

Bart de Jonge

TeamSoft Groep

T: +31 - (0)78-6999333

M: +31 - 6-13450680

E: bart.de.jonge_at_teamsoft.nl