java.lang.ClassCastException: org.jboss.mq.SpyTopic

Hey all,

I've been struggling with JBoss queues over the past few days, and I think I'm almost there, but now I'm getting a new exception.

Properties env =new Properties();

env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");

env.put(Context.PROVIDER_URL,"jnp://<remote ip address>:1099");

topicName =new String("<Topic Name>");

System.out.println("Topic name is " + topicName);

// Create a JNDI API InitialContext object if none exists

try{

jndiContext =new InitialContext(env);

}catch (NamingException e){

System.out.println("Could not create JNDI API " +

"context: " + e.toString());

System.exit(1);

}

try{

topicConnectionFactory = (TopicConnectionFactory)

jndiContext.lookup("topic/<Topic Name>");

topic = (Topic) jndiContext.lookup(topicName);

}catch (NamingException e){

System.out.println("JNDI API lookup failed: " +

e.toString());

System.exit(1);

}

The exception being thrown is:

Exception in thread "main" java.lang.ClassCastException: org.jboss.mq.SpyTopic

at SimpleTopicReceiver.main(SimpleTopicReceiver.java:43)

I haven't found much help online on this issue. Any help would be appreciated. The line throwing the exception is:

topicConnectionFactory = (TopicConnectionFactory)

jndiContext.lookup("topic/<Topic Name>");

Thanks

[2296 byte] By [Trunks7712a] at [2007-11-27 6:02:28]
# 1

Hey all,

If anybody cared I fixed the problem. When you do the jndi lookup it's not the topic name persay. Since I was using JBoss it was a standard.

topicConnectionFactory = (TopicConnectionFactory)

jndiContext.lookup("UIL2ConnectionFactory");

Everything is working now and it's reading messages fine. I hope that helps somebody else who is stuck :).

Trunks7712a at 2007-7-12 16:43:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...