Link to home
Start Free TrialLog in
Avatar of inzaghi
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.ClassCastException: javax.naming.Reference

Is this something to do with the Connection Factory not being created correctly
SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Object o = context.lookup(jndiRef)

System.out.println(o.getClass());
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, why are you looking up for a factory? You should probably be using:

QueueConnection obj = ( QueueConnection ) context.lookup ( jndiRef ) ;
Or is this for creating some stand-alone client to Websphere MQ JMS?
Avatar of inzaghi
inzaghi

ASKER

the class it returns is javax.naming.Reference , could this be a classpath issue?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.