This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Getting very strange exception: JMS in EJB3, JBoss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Getting very strange exception: JMS in EJB3, JBoss" Watch "Getting very strange exception: JMS in EJB3, JBoss" New topic
Author

Getting very strange exception: JMS in EJB3, JBoss

Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
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 ]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9924
    
158

Root exception is java.lang.ClassCastException: org.jboss.naming.LinkRefPair cannot be cast to org.jboss.naming.LinkRefPair


Looks like a classloader issue. Are you packaging any jboss specific jar files in your application package? If yes, then remove those jar files. Those jars are already available in the JBoss lib folder.


[My Blog] [JavaRanch Journal]
 
Consider Paul's rocket mass heater.
 
subject: Getting very strange exception: JMS in EJB3, JBoss
 
Similar Threads
mdb doesn't catch messages in point2point
TimeOut in sending and receiving message in MQ5.3 thorugh RAD 8
which jar files need to run normal JMS application
query Regarding name not bound exception in EJB3...
Help in MDB with javax.jms