Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

843830May 31 2007 — edited Oct 11 2007
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 8 2007
Added on May 31 2007
4 comments
143 views