[jboss-user] [Beginners Corner] - Problem looking with CastClassException on JBossConnectionFa

Karen.Kramer do-not-reply at jboss.com
Tue Aug 26 16:41:23 EDT 2008


Using JBoss EAP 3.4.0 with JBossMessaging 1.4.0.SP3
We are migrating from JBoss 4.2.2 GA with JBossMQ

I was able to download the example client code for a basic send/receive with a queue....the client runs perfectly:

Here is remote client code which I could run and results up to getting the Session object :

 public void setupPTP() 
        throws JMSException, 
               NamingException 
    { 

    	Hashtable env = new Hashtable();

        env.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
        env.put( Context.PROVIDER_URL, "localhost:1099" );
        env.put( Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );

        InitialContext iniCtx = new InitialContext(env);
        
        System.out.println("Here 1");
        Object tmp = iniCtx.lookup("ConnectionFactory");
        System.out.println("Got the tmp object: tmp is " + tmp.toString());
        QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
        System.out.println("Got the QueueConnectionFactory: + qcf is " + qcf.toString());
     
        conn = qcf.createQueueConnection();
        System.out.println("Got the QueueConnection:  conn is " + conn.toString());
        que = (Queue) iniCtx.lookup("queue/EventSubmitServiceCommandQueue");
        System.out.println("Got the Que:  que is " + que.toString());
        session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
        System.out.println("Got the Session:  session is " + session.toString());
        conn.start();
    } 

RESULTS: THIS IS GOOD!
Got the tmp object: tmp is JBossConnectionFactory->ConnectionFactoryDelegate[jboss.messaging.connectionfactory:service=ConnectionFactory, SID=0]
Got the QueueConnectionFactory: + qcf is JBossConnectionFactory->ConnectionFactoryDelegate[jboss.messaging.connectionfactory:service=ConnectionFactory, SID=0]
Got the QueueConnection:  conn is JBossConnection->ConnectionDelegate[13994297, ID=36-6udisckf-1-1a66ockf-7c3hoj-l1jvs4, SID=0]
Got the Que:  que is JBossQueue[EventSubmitServiceCommandQueue]
Got the Session:  session is JBossSession->SessionDelegate[18012736, ID=46-zxdisckf-1-1a66ockf-7c3hoj-l1jvs4]

PROBLEM
OK, so now I paste the same exact code into a java class inside of our application and I am getting a ClassCastException in the line:

 QueueConnectionFactory qcf = ( QueueConnectionFactory ) tmp;

tmp is an instance of JBossConnectionFactory which (when I checked the source noticed) implements QueueConnectionFactory...so why won't it cast?

Does this have to do with the JNDI tree? Here is mine(part)

java: Namespace
  +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  +- jaas (class: javax.naming.Context)
  |   +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
  |   +- messaging (class: org.jboss.security.plugins.SecurityDomainContext)
  |   +- jmx-console (class: org.jboss.security.plugins.SecurityDomainContext)
  |   +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
  +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
  +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
  +- comp.ejb3 (class: javax.naming.Context)
  |   NonContext: null
  +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
  +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
  +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
  +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
  +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  +- jdbcISAC (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  +- Mail (class: javax.mail.Session)
  +- jdbcScanOptics (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  +- comp.original (class: javax.namingMain.Context)
  +- timedCacheFactory (class: javax.naming.Context)
Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
  +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
  +- comp (class: javax.naming.Context)

Global JNDI Namespace
  +- CustomerNumberAdministration (proxy: $Proxy141 implements interface com.cbc.isac.ejb20.customernumber.CustomerNumberAdministrationHome,interface javax.ejb.Handle)
  +- CacheLoad (proxy: $Proxy143 implements interface com.cbc.isac.ejb20.cacheload.TpCodesHome,interface javax.ejb.Handle)
  +- ClusteredXAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  +- XAConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  +- queue (class: org.jnp.interfaces.NamingContext)
  |   +- ExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- EventSubmitServiceCommandQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- EventCompleteServiceCommandQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- EventSubmitErrorQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- ScanOpticsServiceCommandQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- testDistributedQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- QueueWithOwnDLQAndExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- EventSubmitServiceCommanQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- DisputeStatusErrorQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- ScanOpticsSerivceCommandQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- EventCompleteErrorQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- testQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- D (class: org.jboss.jms.destination.JBossQueue)
  |   +- PrivateDLQ (class: org.jboss.jms.destination.JBossQueue)
  |   +- C (class: org.jboss.jms.destination.JBossQueue)
  |   +- B (class: org.jboss.jms.destination.JBossQueue)
  |   +- A (class: org.jboss.jms.destination.JBossQueue)
  |   +- PrivateExpiryQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- DisputeStatusMessageQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- ScanOpticsErrorQueue (class: org.jboss.jms.destination.JBossQueue)
  |   +- DLQ (class: org.jboss.jms.destination.JBossQueue)
  |   +- QueueWithOwnRedeliveryDelay (class: org.jboss.jms.destination.JBossQueue)
  |   +- ex (class: org.jboss.jms.destination.JBossQueue)
  +- EventComplete (proxy: $Proxy115 implements interface com.cbc.isac.ejb20.eventcomplete.EventCompleteHome,interface javax.ejb.Handle)
  +- MessageManagement (proxy: $Proxy129 implements interface com.cbc.isac.ejb20.messagemanagement.MessageManagementHome,interface javax.ejb.Handle)
  +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
  +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
  +- PaymentCalculator (proxy: $Proxy117 implements interface com.cbc.isac.ejb20.payment.PaymentCalculatorHome,interface javax.ejb.Handle)
  +- ContactMaintenance (proxy: $Proxy111 implements interface com.cbc.isac.ejb20.contactinfo.ContactMaintenanceHome,interface javax.ejb.Handle)
  +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
  +- Security (proxy: $Proxy105 implements interface com.cbc.isac.ejb20.security.SecurityHome,interface javax.ejb.Handle)
  +- ScanOptics (proxy: $Proxy89 implements interface com.cbc.isac.ejb20.scanoptics.ScanOpticsHome,interface javax.ejb.Handle)
  +- UserTransactionSessionFactory (proxy: $Proxy14 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
  +- DocumentMaintenance (proxy: $Proxy91 implements interface com.cbc.isac.ejb20.document.DocumentMaintenanceHome,interface javax.ejb.Handle)
  +- FeeMaintenance (proxy: $Proxy107 implements interface com.cbc.isac.ejb20.feemaint.FeeMaintenanceHome,interface javax.ejb.Handle)
  +- DocTemplateMaintenance (proxy: $Proxy139 implements interface com.cbc.isac.ejb20.doctemplate.DocTemplateMaintenanceHome,interface javax.ejb.Handle)
  +- Inquiry (proxy: $Proxy99 implements interface com.cbc.isac.ejb20.inquiry.InquiryHome,interface javax.ejb.Handle)
  +- console (class: org.jnp.interfaces.NamingContext)
  |   +- PluginManager (proxy: $Proxy49 implements interface org.jboss.console.manager.PluginManagerMBean)
  +- EventSubmit (proxy: $Proxy119 implements interface com.cbc.isac.ejb20.eventsubmit.EventSubmitHome,interface javax.ejb.Handle)
  +- PaymentUtil (proxy: $Proxy101 implements interface com.cbc.isac.ejb20.payment.PaymentUtilHome,interface javax.ejb.Handle)
  +- topic (class: org.jnp.interfaces.NamingContext)
  |   +- testDurableTopic (class: org.jboss.jms.destination.JBossTopic)
  |   +- TopicWithOwnRedeliveryDelay (class: org.jboss.jms.destination.JBossTopic)
  |   +- testTopic (class: org.jboss.jms.destination.JBossTopic)
  |   +- testDistributedTopic (class: org.jboss.jms.destination.JBossTopic)
  |   +- TopicWithOwnDLQAndExpiryQueue (class: org.jboss.jms.destination.JBossTopic)
  |   +- securedTopic (class: org.jboss.jms.destination.JBossTopic)
  +- StatusListsSearch (proxy: $Proxy95 implements interface com.cbc.isac.ejb20.statuslists.StatusListsSearchHome,interface javax.ejb.Handle)
  +- XmlToCpuConversion (proxy: $Proxy127 implements interface com.cbc.isac.ejb20.xmltocpu.XmlToCpuConversionHome,interface javax.ejb.Handle)
  +- EventAddressSearch (proxy: $Proxy135 implements interface com.cbc.isac.ejb20.search.EventAddressSearchHome,interface javax.ejb.Handle)
  +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
  +- AdverseActionMaintenance (proxy: $Proxy93 implements interface com.cbc.isac.ejb20.adverse.AdverseActionMaintenanceHome,interface javax.ejb.Handle)
  +- EventCompliance (proxy: $Proxy125 implements interface com.cbc.isac.ejb20.compliance.EventComplianceHome,interface javax.ejb.Handle)
  +- ReportSubmissionManager (proxy: $Proxy131 implements interface com.cbc.isac.ejb20.eventcomplete.ReportSubmissionManagerHome,interface javax.ejb.Handle)
  +- DisputeMaintenance (proxy: $Proxy109 implements interface com.cbc.isac.ejb20.dispute.DisputeMaintenanceHome,interface javax.ejb.Handle)
  +- ClusteredConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  +- ACL (proxy: $Proxy121 implements interface com.cbc.isac.ejb20.acl.ACLHome,interface javax.ejb.Handle)
  +- InsertMaintenance (proxy: $Proxy123 implements interface com.cbc.isac.ejb20.insert.InsertMaintenanceHome,interface javax.ejb.Handle)
  +- Iccon (proxy: $Proxy103 implements interface com.cbc.isac.ejb20.iccon.IcconHome,interface javax.ejb.Handle)
  +- ACDV (proxy: $Proxy133 implements interface com.cbc.isac.ejb20.acdv.AcdvHome,interface javax.ejb.Handle)
  +- EventMaintenance (proxy: $Proxy137 implements interface com.cbc.isac.ejb20.event.EventMaintenanceHome,interface javax.ejb.Handle)
  +- jmx (class: org.jnp.interfaces.NamingContext)
  |   +- invoker (class: org.jnp.interfaces.NamingContext)
  |   |   +- RMIAdaptor (proxy: $Proxy48 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
  |   +- rmi (class: org.jnp.interfaces.NamingContext)
  |   |   +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
  +- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
  +- HistoryMaintenance (proxy: $Proxy113 implements interface com.cbc.isac.ejb20.history.HistoryMaintenanceHome,interface javax.ejb.Handle)
  +- UserAdministration (proxy: $Proxy97 implements interface com.cbc.isac.ejb20.useradmin.UserAdministrationHome,interface javax.ejb.Handle)


I've searched on the net and it doesn't appear to be a problem for anyone else, so I figured I was doing something ignorant...any help?

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

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



More information about the jboss-user mailing list