[JBoss-user] [Messaging, JMS JBossMQ] - Re: Class Cast Exception -- By HelloDr

2006-07-05 Thread genman

What's the type of the object?  E.g. 

Object o = ...
System.out.println(class is  + o.getClass());

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3955686#3955686

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3955686

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Messaging, JMS JBossMQ] - Re: Class Cast Exception -- By HelloDr

2006-07-05 Thread hellodr
Thanks genman.. 

The type of the Object is org.jboss.mq.SpyQueue. But I dont need to use 
SpyQueue or SpyConnectionFactory. I prefer to use QueueConnectionFactory and 
Queue Connection in my program. But When do a JNDI lookup like
SpyConnectionFactory factory = (SpyConnectionFactory) 
ctx.lookup(ConnectionFactory);
It returs Object of SpyConnectionFactory. What should I do in my Application 
Server Settings to return QueueConnectionFactory. Also please let me know the 
JNDI name for it. 
My full Program Code is (Which Throws Exception)


package com.echain.contacts.web.action;
import java.io.PrintWriter;

import javax.jms.QueueConnection;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jboss.mq.SpyConnectionFactory;
import org.jboss.mq.SpyQueue;

public class ServerAction extends Action {

QueueConnection qCon;
QueueSession qSess;
SpyQueue queue;
QueueSender qSender;
PrintWriter pw;

public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest req, HttpServletResponse res) throws Exception {
try {
pw = res.getWriter();
System.out.println(\n\n*** Creating Queue 
***\n\n);
pw.println(*** Creating Queue ***);
createQueue();
System.out.println(\n\n*** Created Queue 
***\n\n);
pw.println(*** Created Queue ***);
System.out.println(\n\n*** Sending Message to Queue 
***\n\n);
pw.println(*** Sending Message to Queue ***);
sendMessageToQueue(THis is the Message);
System.out.println(\n\n*** Message Sent to Queue 
***\n\n);
pw.println(*** Message Sent to Queue ***);
} catch (Exception e) {
e.printStackTrace();
}

return mapping.findForward(forward.success);
}

public void createQueue() throws Exception{
InitialContext ctx = new InitialContext();
System.out.println(\n\nFactory is :  + 
ctx.lookup(ConnectionFactory) + \n\n);
SpyConnectionFactory factory = (SpyConnectionFactory) 
ctx.lookup(ConnectionFactory);
qCon = factory.createQueueConnection();
ctx = new InitialContext();
Object o = ctx.lookup(queue/echnQueue);
System.out.println(\n\nQueue is :  + o.getClass() + \n\n);
queue = (SpyQueue) ctx.lookup(queue/echnQueue);
qSess = qCon.createQueueSession(false, 
QueueSession.AUTO_ACKNOWLEDGE);
qCon.start();
}

public void sendMessageToQueue(String message) throws Exception{
qSender = qSess.createSender(queue);
TextMessage tm = qSess.createTextMessage(message);
qSender.send(tm);
qSender.close();
System.out.println(\n\n\n\n*\n\nMessage Send 
to Queue And QSender is Closed\n\n\n\n\n);
pw.println(* Message Send to Queue And QSender 
is Closed );
}
}

In the above marked redline I am getting an exception 
java.lang.LinkageError: Class javax/jms/QueueConnection violates loader 
constraints

Please help me out 

Regards,
Dharma


View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3955714#3955714

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3955714

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user