File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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

Aruna Kumar Roula
Greenhorn

Joined: Dec 30, 2005
Posts: 8
Hi,

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:

com.ibm.ws.admin.client_6.1.0.jar
com.ibm.ws.webservices.thinclient_6.1.0.jar

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

-Arun


Aruna Kumar Roula<br />Banglore
Helder da Rocha
Greenhorn

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 com.ibm.* JARs from the ${WAS_HOME}\AppServer\plugins

Helder.
Riaz Mogal
Greenhorn

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(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
Rahul K Gupta
Greenhorn

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();
try
{
hTableforProp.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
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");
jmsConnxn=jmsQCF.createQueueConnection();
System.out.println("Starting the connection!!");
jmsConnxn.start();
jmsSession=jmsConnxn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
System.out.println("Looking up the Request Queue name in the JNDI Store!!");
jmsQueue=(javax.jms.Queue)ctx.lookup("myQueue");
jmsQsender=jmsSession.createSender(jmsQueue);
System.out.println("Created the sesssion successfully!!");
outMessage = jmsSession.createTextMessage();
outMessage.setText("Test Message on " + new Date());
jmsQsender.send(outMessage );
}
catch (Exception E)
{
E.printStackTrace();
}
} // 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.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

"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 ]

SCJP, SCWCD.
|Asking Good Questions|
shafiullah shaik
Greenhorn

Joined: Dec 01, 2008
Posts: 8
HI ,

In our project we are using Websphere Application server 7.0.0.11
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);
try
{
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