EJB3 MDB Annotations not working.
thenewmexican Oct 29, 2009 9:12 AM
I attempting to deploy my MDB as follows.
import java.util.logging.Logger;
import javax.ejb.MessageDriven;
import javax.ejb.ActivationConfigProperty;
import javax.jms.Message;
import javax.jms.MessageListener;
/*
* The MDB
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/orderQueue")
})
public classOrderMDB implements MessageListener {
public void onMessage(Message recvMsg){
log.info("----------------");
log.info("Received message");
log.info("----------------");
}
private static Logger log = Logger.getLogger(OrderMDB.class.getName());
}
/*
* The client
*/
public void placeOrderUsing(Order anOrder){
/*
* persist and log this transaction,order
*/
try {
QueueConnection cnn = null;
QueueSender sender = null;
QueueSession session = null;
InitialContext ctx = new InitialContext();
log.info("obtained initial context");
javax.jms.Queue queue = (Queue) ctx.lookup("queue/orderQueue");
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
cnn = factory.createQueueConnection();
session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
ObjectMessage msg = session.createObjectMessage();
msg.setObject(anOrder);
sender = session.createSender(queue);
sender.send(msg);
log.info("message sent to orderQueue");
}
catch(Exception ex1){
ex1.printStackTrace();
}
}
I receive the following stack trace indicating that the name orderQueue is not bound.
javax.naming.NameNotFoundException: orderQueue not bound
06:57:42,804 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
06:57:42,804 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
06:57:42,804 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
06:57:42,804 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
06:57:42,804 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:399)
06:57:42,805 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
06:57:42,805 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
06:57:42,805 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:392)
What am I doing wrong.
Thanks in advance.