-
1. Re: ClassCastException looking up ConnectionFactory
stephanenicoll Jul 3, 2003 3:46 AM (in response to mfrost)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 -
2. Re: ClassCastException looking up ConnectionFactory
mfrost Jul 3, 2003 4:28 AM (in response to mfrost)Yes i'm trying to run this from a remote client.
I have the following in my classpath:
jboss-client.jar
log4j.jar
jnp-client.jar
jboss-common-client.jar
my jndi properties are:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://127.0.0.1:1099/
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
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!
Cheers
Mark -
3. Re: ClassCastException looking up ConnectionFactory
stephanenicoll Jul 3, 2003 4:35 AM (in response to mfrost)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 :
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=127.0.0.1
try to put everything in the client directory in your classpath. -
4. Re: ClassCastException looking up ConnectionFactory
mfrost Jul 3, 2003 5:38 AM (in response to mfrost)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.
Best regards
mark