Classcast exception [message #1749510] |
Wed, 07 December 2016 09:58  |
Eclipse User |
|
|
|
Hi all,
in my bundle I'm using qpid libraries to establish an AMQP connection, but I have the following error:
java.lang.ClassCastException: org.apache.qpid.jms.JmsConnectionFactory cannot be cast to org.apache.qpid.jms.JmsConnectionFactory
The java code is:
Properties props = new Properties();
props.put(NAMING_FACTORY_INITIAL_KEY, NAMING_FACTORY_INITIAL_VALUE);
props.put(FACTORY_LOOKUP_KEY, "amqps://" + host + ":" + port + "?amqp.idleTimeout=6000000");
props.put(QUEUE_LOOKUP_KEY, "/devices/messages/events");
Context context = new InitialContext(props);
factory = (JmsConnectionFactory) context.lookup("myFactoryLookup");
destination = (JmsQueue) context.lookup("myQueueLookup");
String username = deviceId + deviceType + "@sas." + hostname;
connection = factory.createConnection(username, token);
System.out.println("Setted client");
It seems to me that the Kura classloader is loading two instances of the same jar. is it possible?
If is that the case, how can I avoid this situation?
In a stand alone version of the same code there are no errors at all.
|
|
|
Re: Classcast exception [message #1749708 is a reply to message #1749510] |
Fri, 09 December 2016 17:03  |
Eclipse User |
|
|
|
Hello,
How are you loading the qpid libraries? Are you adding them to the classpath of your bundle? Are you adding them via a separate bundle in the OSGi runtime? Also, providing your MANIFEST.MF file is often helpful.
Thanks,
--Dave
|
|
|
Powered by
FUDForum. Page generated in 0.04880 seconds