File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes java.lang.ClassCastException: javax.naming.Reference incompatible with QueueConnectio Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "java.lang.ClassCastException: javax.naming.Reference incompatible with QueueConnectio" Watch "java.lang.ClassCastException: javax.naming.Reference incompatible with QueueConnectio" New topic

java.lang.ClassCastException: javax.naming.Reference incompatible with QueueConnectio

Aruna Kumar Roula

Joined: Dec 30, 2005
Posts: 8

I am writting a JMS client for my application which is running on WebSphere 6.1.13

When i tring to look up QueueConnectionFactory, getting following exception.

QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup("jms/RTDSQueueConnectionFactory");

May 23, 2008 12:48:58 PM
WARNING: jndiGetObjInstNoop

java.lang.ClassCastException: javax.naming.Reference incompatible with javax.jms.QueueConnectionFactory

12:48:58.078 runPreInit:176 P=136765 =0:CT ORBRas[default] java.lang.ClassNotFoundException: (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(
at sun.rmi.server.LoaderHandler.loadClass(
at java.rmi.server.RMIClassLoader$2.loadClass(
at java.rmi.server.RMIClassLoader.loadClass(
at java.rmi.server.RMIClassLoader.loadClass(
at javax.rmi.CORBA.Util.loadClass(
at org.omg.CORBA.ORB.init(
at javax.naming.InitialContext.lookup(

I have put the following jars on my project classpath on eclipse:

Please help me.. It is too urgent form me.
Thanks a lot in advance.


Aruna Kumar Roula<br />Banglore
Helder da Rocha

Joined: Jun 11, 2008
Posts: 1
I fixed this problem including the following JARs in my client's classpath. I'm using WAS 6.1 connected to MQ 6 in Windows:

1) Configure your project to use the IBM JRE @ ${WAS_HOME}\AppServer\java as your runtime.
2) Include the JARs in ${WAS_HOME}\AppServer\lib and the JARs in ${WAS_HOME}\AppServer\lib\WMQ\java\lib
3) Include all the* JARs from the ${WAS_HOME}\AppServer\plugins

Riaz Mogal

Joined: Dec 11, 2008
Posts: 2
Can you please tell me how did you solved the below error. Not sure which JAR has the class.

java.lang.NoClassDefFoundError: org.eclipse.hyades.collection.correlation.ICorrelatorData
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(
at java.lang.J9VMInternals.initialize(
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(

Here are some of the Jars which I added in classpath.

export WAS61_HOME=/opt/IBM/WebSphere/AppServer61
export WAS61_JARS=$WAS61_HOME/runtimes/$WAS61_HOME/runtimes/$WAS61_HOME/plugins/
export WAS61_MQ_JARS=$WAS61_HOME/lib/WMQ/java/lib/$WAS61_HOME/lib/WMQ/java/lib/$WAS61_HOME/lib/WMQ/java/lib/dhbcore.jar
Rahul K Gupta

Joined: Dec 22, 2008
Posts: 1
Hi, my sample code to connect to a MQ(v6.0)Queue while making exclusive use of javax.jms APIs ( J2EE v 1.5 and JDK v 1.6) is as follows -
import javax.jms.*;
import java.util.*;
import javax.naming.*;
class accessMQ
public static void main ( String args[])

Context ctx = null;
QueueConnectionFactory jmsQCF = null;
QueueConnection jmsConnxn = null;
QueueSession jmsSession = null;
javax.jms.Queue jmsQueue = null;
QueueSender jmsQsender=null;
TextMessage outMessage=null;
Hashtable hTableforProp = new Hashtable();
hTableforProp.put(Context.PROVIDER_URL, "file:/C:/JNDI-Directory");

ctx=new InitialContext(hTableforProp);
System.out.println("Looking up the QCF name in the JNDI Store!!");
jmsQCF =(QueueConnectionFactory) ctx.lookup("MyQCF");
System.out.println("Starting the connection!!");
System.out.println("Looking up the Request Queue name in the JNDI Store!!");
System.out.println("Created the sesssion successfully!!");
outMessage = jmsSession.createTextMessage();
outMessage.setText("Test Message on " + new Date());
jmsQsender.send(outMessage );
catch (Exception E)
} // main method ends here.
} // class accessMQ ends here
I would like to share following points which I confirmed while resolving this exact issue-
1.)Switching the JDK vendor from SUN to IBM didn't help me. I get the same exception for either of those.
2.) Only the following four JAR files are additionally required to successfully execute the code seen above - fscontext.jar,providerutil.jar, j2ee.jar, lost a lot of time in trying to figure out this exact dependency. I hope others find it helpful in saving their time.
Amit Ghorpade

Joined: Jun 06, 2007
Posts: 2718

"Rahul KG" welcome to Javaranch
looks like your display name does not follow the Javaranch Naming policy .
Basically your display name must consist of a first name and a last name(no initials for last name) separated by a space and must not be obviously fictitious.
Please change your display name using the My Profile link above.
So please take a moment of your time to adjust your display name so that it includes a valid last name also.
[ December 22, 2008: Message edited by: Amit Ghorpade ]

|Asking Good Questions|
shafiullah shaik

Joined: Dec 01, 2008
Posts: 8
HI ,

In our project we are using Websphere Application server
When we tried to send mails we are getting the below exception

[financing_tools_gcps] [GcpsEmailSender] [03/04 09:23:19] [DEBUG] [Severity 4] [R2fSendStatusApp] Initializing context and mail session
[financing_tools_gcps] [GcpsEmailSenderFactory] [03/04 09:23:22] [ERROR] [Severity 2] [R2fSendStatusApp] GcpsEmailSenderFactor failed to send eMail sendMail(String to, String from, String subject, String text, String mimeType) javax.naming.Reference incompatible with javax.mail.Session
[financing_tools_gcps] [GcpsEmailSenderFactory] [03/04 09:23:22] [DEBUG] [Severity 4] [R2fSendStatusApp] <-- GcpsEmailSenderFactory sendMail(String to, String from, String subject, String text, String mimeType) with exception java.lang.ClassCastException: javax.naming.Reference incompatible with javax.mail.Session
[financing_tools_gcps] [R2fSendStatusApp] [03/04 09:23:22] [ERROR] [Severity 2] [R2fSendStatusApp] Gcps Exception occured while sending mail incompatible with javax.mail.Session

THe code which we used is:
private void init()
throws GcpsException
logCtx.debug(ENTRY_LOG, "--> void init ( ) ");
Hashtable hashtable = new Hashtable();
String s = ApplicationContextFactory.singleton().getApplicationContext().getConfigParameter("javaMailInitialContextFactory");
String s1 = ApplicationContextFactory.singleton().getApplicationContext().getConfigParameter("jndiProviderUrl");
String s2 = ApplicationContextFactory.singleton().getApplicationContext().getConfigParameter("javaMailSessionJndiName");
hashtable.put("java.naming.factory.initial", s);
hashtable.put("java.naming.provider.url", s1);
logCtx.debug(APP_LOG, "Initializing context and mail session");
logCtx.debug(APP_LOG, s);
logCtx.debug(APP_LOG, s1);
logCtx.debug(APP_LOG, s2);
InitialContext initialcontext = new InitialContext(hashtable);
logCtx.debug(APP_LOG, "Testing 1");
super.mailSession = (Session)initialcontext.lookup(s2);
logCtx.debug(APP_LOG, "Initializing context and mail session ended");
catch(NamingException namingexception)
GcpsException gcpsexception = new GcpsException(namingexception.getMessage());
logCtx.error(APP_LOG, (new StringBuilder()).append("Naming exception occured during initiliazing the session and context ").append(namingexception.getMessage()).toString());
logCtx.debug(EXIT_LOG, "<-- void init ( ) with Naming Exception");
throw gcpsexception;
logCtx.debug(EXIT_LOG, "void init ( ) ");

When we use Websphere Application server 6.1 We are happily receiving mails .
IN the class path I have set the WAS 7 compatible naming.jar and namingclient.jar

Please let me know if something else is to be configured.
can some one please help me out in this.
It is sorta covered in the JavaRanch Style Guide.
subject: java.lang.ClassCastException: javax.naming.Reference incompatible with QueueConnectio