inzaghi
asked on
java.lang.ClassCastException: javax.naming.Reference thrown whilst doing a look up
We are trying to connect to a mq queue
QueueConnectionFactory factory = (QueueConnectionFactory) context.lookup(jndiRef)
but we are getting the exception
java.lang.ClassCastExcepti on: javax.naming.Reference
Is this something to do with the Connection Factory not being created correctly
QueueConnectionFactory factory = (QueueConnectionFactory) context.lookup(jndiRef)
but we are getting the exception
java.lang.ClassCastExcepti
Is this something to do with the Connection Factory not being created correctly
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW, why are you looking up for a factory? You should probably be using:
QueueConnection obj = ( QueueConnection ) context.lookup ( jndiRef ) ;
QueueConnection obj = ( QueueConnection ) context.lookup ( jndiRef ) ;
Or is this for creating some stand-alone client to Websphere MQ JMS?
ASKER
the class it returns is javax.naming.Reference , could this be a classpath issue?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
thanks
:-)
So what exactly was the problem?
I guess the class-path.
I'm pretty sure it was, but for the benefit of others with same problem reading this post it should be stated (especially when you accept every suggestion mentioned).
Agreed.
System.out.println(o.getCl