[jboss-user] [JBoss Messaging] - ClassCastException looking up ConnectionFactory

markstrecker do-not-reply at jboss.com
Thu May 21 15:42:13 EDT 2009


Hello,

I'm trying to get the P2P example working so that my webapp(running in JBoss 4.2.3) can write and consume messages. I used the example from the JBoss docs (http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html-single/index.html#JMS_Examples-A_Point_To_Point_Example) and when I start the webapp and execute my JNDI lookup, I get this error :
java.lang.ClassCastException: org.jboss.mq.SpyConnectionFactory cannot be cast to javax.jms.QueueConnectionFactory

So, I change it to a SpyConnectionFactory and get a similar error about SpyQueue. I change that and then get this : 


  | java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/web/tomcat/service/WebAppClassLoader) previously initiated loading for a different type with name "javax/jms/QueueConnection"
  | 	java.lang.ClassLoader.defineClass1(Native Method)
  | 	java.lang.ClassLoader.defineClass(Unknown Source)
  | 	java.security.SecureClassLoader.defineClass(Unknown Source)
  | 	org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1814)
  | 	org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
  | 	org.jboss.web.tomcat.service.WebAppClassLoader.findClass(WebAppClassLoader.java:75)
  | 	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
  | 	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
  | 	java.lang.ClassLoader.loadClassInternal(Unknown Source)
  | 

Here's the original version of my code.


  | package test.jms;
  | 
  | import javax.jms.JMSException;
  | import javax.jms.Queue;
  | import javax.jms.QueueConnection;
  | import javax.jms.QueueConnectionFactory;
  | import javax.jms.QueueReceiver;
  | import javax.jms.QueueSender;
  | import javax.jms.QueueSession;
  | import javax.jms.TextMessage;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | 
  | public class QueueSetup
  | {
  |     public void sendRecvAsync(String text) throws JMSException, NamingException
  |     {
  |         InitialContext iniCtx = new InitialContext();
  |         Object tmp = iniCtx.lookup("ConnectionFactory");
  |         QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
  |         QueueConnection conn = qcf.createQueueConnection();
  |         Queue que = (Queue) iniCtx.lookup("queue/A");
  |         QueueSession session = conn.createQueueSession(false,
  |                 QueueSession.AUTO_ACKNOWLEDGE);
  |         conn.start();
  | 
  |         // Set the async listener
  |         QueueReceiver recv = session.createReceiver(que);
  |         recv.setMessageListener(new MyMessageListener());
  | 
  |         // Send a text msg
  |         QueueSender send = session.createSender(que);
  |         TextMessage tm = session.createTextMessage("This is a test");
  |         send.send(tm);
  |         send.close();
  |     }
  | }
  | 

Any ideas about what's wrong?(I did try java:JmsXA with similar results) Is there some setup that I missed?
TIA

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4232574#4232574

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4232574



More information about the jboss-user mailing list