This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes ClassCastException with JMS. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ClassCastException with JMS." Watch "ClassCastException with JMS." New topic
Author

ClassCastException with JMS.

karthik hv
Greenhorn

Joined: Jun 11, 2006
Posts: 5
Hi,

I am new to the JMS Concept.
I tried with few example progs from the net for JMS.

When I try to look up, I get the following error.

java.lang.ClassCastException: weblogic.jms.common.DestinationImpl
at icomsMsgQueue.MessageProcessor.initSend(MessageProcessor.java:32)
at icomsMsgQueue.ICOMSMsgQueue.sendMsg(ICOMSMsgQueue.java:51)
at icomsMsgQueue.TestCode.main(TestCode.java:11)


This is the source:

public void initSend(String QCFName, String QName, String user, String pass, boolean transacted)
{
try
{
//qcf.createQueueConnection();
System.out.println("3333+++++33333");
qcf = (QueueConnectionFactory) initProcess(QCFName);
System.out.println("3333-----33333");
q = (Queue) initProcess(QName);
qc = ((user != null) && (pass != null)? qcf.createQueueConnection(user, pass): qcf.createQueueConnection());
qs = qc.createQueueSession(transacted, Session.AUTO_ACKNOWLEDGE);
snd = qs.createSender(q);
System.out.println("qcf:"+qcf+" q:"+q+" qc:"+qc+" qs:"+qs+" snd:"+snd);

qc.start();
}
catch(Exception e)
{
e.printStackTrace();
}
}



public Object initProcess(String name)
{
try
{
Hashtable ht = new Hashtable();
System.out.println("11111");
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.T3InitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
//ht.put("java.naming.security.principal", "weblogic");
//ht.put("java.naming.security.credentials", "welcome");
Context ctx = new InitialContext(ht);
retLookup = ctx.lookup(name);
ctx.close();
System.out.println("1111++++1111"+retLookup);
}
catch(Exception e)
{
e.printStackTrace();
}
return retLookup;
}



Kindly tell me what I am missing out.
If you need any more info, pls let me know.
Navaneetha krishnan
Greenhorn

Joined: Sep 21, 2004
Posts: 26
I also faced similar ClassCastException. It got resolved somehow. I am not sure what I did. You can try adding relevant jars - jms.jar,
jbossall-client.jar [I am using jBoss as JMS provider]

Also, make sure that jndi properties are set properly.



-- Navanee
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Change reference from Queue to Destination
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ClassCastException with JMS.