• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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

Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 com.ibm.ws.naming.util.Helpers
WARNING: jndiGetObjInstNoop

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

12:48:58.078 com.ibm.rmi.pi.InterceptorManager runPreInit:176 P=136765 =0:CT ORBRas[default] java.lang.ClassNotFoundException: com.ibm.ws.activity.remote.cos.ActivityServiceClientInterceptor (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:386)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:180)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:632)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:214)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:147)
at com.ibm.rmi.util.JDKBridge.loadClassM(JDKBridge.java:293)
at com.ibm.rmi.util.JDKBridge.loadClass(JDKBridge.java:108)
at com.ibm.CORBA.iiop.UtilDelegateImpl.loadClass(UtilDelegateImpl.java:644)
at javax.rmi.CORBA.Util.loadClass(Util.java:252)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:170)
at com.ibm.rmi.corba.ORB.initializeInterceptors(ORB.java:606)
at com.ibm.CORBA.iiop.ORB.initializeInterceptors(ORB.java:1073)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1320)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1211)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1681)
at org.omg.CORBA.ORB.init(ORB.java:364)
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:86)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:179)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:83)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:59)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:102)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:309)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:400)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:117)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:712)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:171)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at com.chordiant.dm.demo.util.DecisionControllerFacade.<init>(DecisionControllerFacade.java:48)
at com.chordiant.dm.demo.prjms.DecisionMaker.calculateSum(DecisionMaker.java:17)
at com.chordiant.dm.demo.prjms.Main.main(Main.java:12)

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.

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 com.ibm.* JARs from the ${WAS_HOME}\AppServer\plugins

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(J9VMInternals.java:66)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:127)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1300)
at com.ibm.rmi.pi.InterceptorManager.runPreInit(InterceptorManager.java:171)

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

export WAS61_HOME=/opt/IBM/WebSphere/AppServer61
export WAS61_JARS=$WAS61_HOME/runtimes/com.ibm.ws.admin.client_6.1.0.jar:$WAS61_HOME/runtimes/com.ibm.ws.webservices.thinclient_6.1.0.jar:$WAS61_HOME/plugins/com.ibm.ws.runtime_6.1.0.jar
export WAS61_MQ_JARS=$WAS61_HOME/lib/WMQ/java/lib/com.ibm.mq.jar:$WAS61_HOME/lib/WMQ/java/lib/com.ibm.mqjms.jar:$WAS61_HOME/lib/WMQ/java/lib/dhbcore.jar
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,com.ibm.mqjms.jar.I lost a lot of time in trying to figure out this exact dependency. I hope others find it helpful in saving their time.
Posts: 2856
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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 ]
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 financing.tools.gcps.common.exceptions.GcpsExceptionjavax.naming.Reference 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!