from where are you running this code? Inside JBoss or from a remote client?
If remote, do not forget to add the jbossclient.jar in your classpath
Yes i'm trying to run this from a remote client.
I have the following in my classpath:
my jndi properties are:
Basically, the JNDI lookup finds the name "ConnectionFactory" but the returned class is javax.naming.Reference. If I use the JNDI API's to list all the name-class pairs it correctly returns (amongst other entries):
ConnectionFactory - org.jboss.mq.SpyConnectionFactory
XAConnectionFactory - org.jboss.mq.SpyXAConnectionFactory
I've tried looking up both ConnectionFactory and XAConnectionFactory but still ClassCastException.
I can't get any of the JBOSS JMS client examples to run because of this problem! Help!
1/ Check that JMS starts fine (see the server.log of the default server)
2/ Here's a code snipet that runs fine on my 3.2.1
jndiContext = new InitialContext();
queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("ConnectionFactory");
queue = (Queue) jndiContext.lookup(queueName);
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
my jndi properties are :
try to put everything in the client directory in your classpath.
Finally got it to work!
As you suggested I added jbossall-client.jar and it works fine now - phew!
Any ideas why this is the case? I could understand a ClassNotFoundException being raised if I didn't have the right CLASSPATH but actually a different class returned from the JNDI lookup - weird!
Maybe I just need to delve deeper into JNDI for an explanation.
Anyway - many thanks for your help.