My Client program is:
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NameingContextFactory");
env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:jnp.interfaces");
env.put(Context.PROVIDER_URL,"jnp://localhost:1099");
QueueConnectionFactory qconFactory;
QueueConnection connection;
QueueSession session;
QueueSender sender;
Queue queue;
TextMessage msg;
qconFactory = (QueueConnectionFactory) ctx.lookup("connectionFactory");
connection = qconFactory.createQueueConnection();
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queue = (Queue) ctx.lookup("queue/testQueue");
msg = session.createTextMessage();
sender = session.createSender(queue);
msg.setText("Hello World");
connection.start();
sender.send(msg);
session.close();
connection.close();
MY MDB is:
@MessageDriven(name="LongProcessMessageBean", activationConfig = {
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/testQueue")
})
public class LongProcessMessageBean implements MessageListener {
@Resource
private MessageDrivenContext context;
public void onMessage(Message message) {
String name = null;
try {
if (message instanceof ObjectMessage) {
ObjectMessage objMessage = (ObjectMessage) message;
Object obj = objMessage.getObject();
if (obj instanceof TextMessage) {
System.out.println("My Message from the Consumer is:"+obj.toString());
} else {
System.err.println("Expecting ProcessDTO in Message");
}
} else {
System.err.println("Expecting Object Message");
}
I am getting exception as on console
19:22:18,328 INFO [STDOUT] MyException is::javax.naming.NamingException: Could not dereference object [Root exception is java.lang.ClassCastException: org.jboss.naming.LinkRefPair cannot be cast to org.jboss.naming.LinkRefPair]
Why is it so??? How to get rid of this error?
Thanks,
ahul
[ November 01, 2008: Message edited by: Rahul Ba ]