• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Getting very strange exception: JMS in EJB3, JBoss

 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 pie came with a little toothpic holding up this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic