1 Reply Latest reply on Nov 8, 2005 10:12 AM by adrian.brock

    ClassCastException when an external client program looksup a

    srramasu

      Hi,

      This seemingly simple issue has wasted a lot of my time. In a hope to find a solution and save my job, i am putting this issue in the forums here to see if i can find a solution. Any help will be highly appreciated.

      I am using JBoss 4.0.1sp1 and have defined JMS connection factories and queues. Everything is fine in the AppServer and all MDB's are deployed and work fine, however the problem is in an external program which should connect to the appserver and put a message in the JMS queue.

      I get a classcast exception while trying to do a lookup for the QueueConnectionFactory. The class being returned by JBoss is org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl as opposed to javax.jms.QueueConnectionFactory which is what i expect to get. The same program works on weblogic and oracle10g appservers.

      The connectionfactory is defined as below in the jms-ds.xml file in jboss..

      <tx-connection-factory>
      <jndi-name>jms/FAPQueueSendConnectionFactory</jndi-name>
      <use-java-context>false</use-java-context>
      <xa-transaction/>
      <rar-name>jms-ra.rar</rar-name>
      <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
      <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.QueueConnectionFactory</config-property>
      <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
      <max-pool-size>20</max-pool-size>
      </tx-connection-factory>

      The client program does a simple lookup for the connection factory and the relevent section is as shown below..

      queueConnectionFactory = (javax.jms.QueueConnectionFactory)jndiContext.lookup("jms/FAPQueueSendConnectionFactory");

      The above line fails with a ClassCastException because JBoss is not returning the connection factory typecasted to javax.jms.QueueConnectionFactory.

      The ConnectionFactory is bound and MDB's deployed are working properly with the same code as above, except for external client programs.

      Please help if you know about this issue, or have faced a similar problem before.

      - Sridhar