Link to home
Create AccountLog in
Java

Java

--

Questions

--

Followers

Top Experts

Avatar of inzaghi
inzaghi

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

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


SOLUTION
Avatar of zzynxzzynx🇧🇪

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of CEHJCEHJ🇬🇧

Object o = context.lookup(jndiRef)

System.out.println(o.getClass());

SOLUTION
Avatar of TimYatesTimYates🇬🇧

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Avatar of Mayank SMayank S🇮🇳

BTW, why are you looking up for a factory? You should probably be using:

QueueConnection obj = ( QueueConnection ) context.lookup ( jndiRef ) ;

Avatar of Mayank SMayank S🇮🇳

Or is this for creating some stand-alone client to Websphere MQ JMS?

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of inzaghiinzaghi

ASKER

the class it returns is javax.naming.Reference , could this be a classpath issue?

SOLUTION
Avatar of CEHJCEHJ🇬🇧

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

ASKER CERTIFIED SOLUTION
Avatar of Mick BarryMick Barry🇦🇺

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

SOLUTION
Avatar of Mayank SMayank S🇮🇳

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Avatar of zzynxzzynx🇧🇪

thanks

Avatar of CEHJCEHJ🇬🇧

:-)

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Mick BarryMick Barry🇦🇺

So what exactly was the problem?

Avatar of Mayank SMayank S🇮🇳

I guess the class-path.

Avatar of Mick BarryMick Barry🇦🇺

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).

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Mayank SMayank S🇮🇳

Agreed.
Java

Java

--

Questions

--

Followers

Top Experts

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.