[jboss-user] [Messaging, JMS & JBossMQ] - java.lang.ClassCastException

vermanaveen do-not-reply at jboss.com
Tue May 1 08:34:32 EDT 2007


Please help.
I am using jboss-4.0.5.GA and have defined JMS connection factories and queues. Everything is fine in the AppServer and all MDB's are deployed and work fine. I get a ClassCastException while trying to do a lookup for the QueueConnectionFactory. The class being returned by JBoss is org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl inline to javax.jms.QueueConnectionFactory which is what i expect to get.

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


  | --------------------------------------------------------------------------------
  | 
  | <tx-connection-factory>
  | <jndi-name>jms/novaJMSConnectionFactory</jndi-name> 
  | <xa-transaction/>          
  | <use-java-context>false</use-java-context>          
  | <track-connection-by-tx/>     	
  | <rar-name>jms-ra.rar</rar-name>          
  | <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>         
  | <security-domain-and-application>JmsXARealm</security-domain-and-application>   
  |  </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/novaJMSConnectionFactory");

The above line fails with a ClassCastException because JBoss is not returning the connection factory typecasted to javax.jms.QueueConnectionFactory; but is returning an object to javax.naming.Reference.

Below is my ejb-jar.xml that I use for creating the EAR file.


  | <?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
  | 
  | <!-- EJB jar xml used on Onshore Development Enviroment-->
  | 
  | <!--
  | 	** This file was automatically generated by EJBGen 2.16
  | 	** Build: 20041105-1607
  | -->
  | <ejb-jar>
  | 	<enterprise-beans>
  | 		<message-driven>
  | 			<ejb-name>MQManager</ejb-name>
  | 			<ejb-class>com.ebw.ejb.mdb.MQManager</ejb-class>
  | 			<transaction-type>Container</transaction-type>
  | 			<message-selector>
  | 				<![CDATA[
  | 					Message_Redirector IS NULL AND Message_Type <> 'Data'
  | 				]]>
  | 			</message-selector>
  | 			<message-driven-destination>
  | 				<destination-type>javax.jms.Queue</destination-type>
  | 			</message-driven-destination>
  | 			
  | 			<resource-ref> 
  |         		<res-ref-name>jms/novaJMSConnectionFactory</res-ref-name>
  |         		<res-type>javax.jms.QueueConnectionFactory</res-type> 
  |         		<res-auth>Container</res-auth> 
  |       		</resource-ref>
  | 
  | 			<!-- 
  | 			<resource-env-ref>
  | 		        <resource-env-ref-name>jms/novaJMSConnectionFactory</resource-env-ref-name>
  | 		        <resource-env-ref-type>javax.jms.QueueConnectionFactory</resource-env-ref-type>
  | 		    </resource-env-ref>
  | 			 -->
  | 			
  | 			<security-identity>
  | 				<run-as>
  | 					<role-name>admin</role-name>
  | 				</run-as>
  | 			</security-identity>
  | 		</message-driven>
  | 	</enterprise-beans>
  | 	<assembly-descriptor>
  | 		<security-role>
  | 			<description>Administrator</description>
  | 			<role-name>admin</role-name>
  | 		</security-role>
  | 		<container-transaction>
  | 			<method>
  | 				<ejb-name>MQManager</ejb-name>
  | 				<method-name>*</method-name>
  | 			</method>
  | 			<trans-attribute>NotSupported</trans-attribute>
  | 		</container-transaction>
  | 	</assembly-descriptor>
  | 	<ejb-client-jar>novaEJBClient.jar</ejb-client-jar>
  | </ejb-jar>
  | 
  | 

Please also find my JBoss.xml file below.


  | <?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN"
  |    "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
  | <!-- jboss xml used on for JBoss deployement-->
  | 
  | <jboss>
  | 	<enterprise-bean>
  | 		<message-driven>
  | 			<ejb-name>MQManager</ejb-name>
  | 				<!--
  | 				@Naveen: commented for the time being
  | 				<pool>
  | 					<instance-pool>15</instance-pool>
  | 				</pool>
  | 				-->
  | 				<destination-jndi-name>jms/novaRequestQueue</destination-jndi-name>
  | 				<resource-ref> 
  | 	       			<res-ref-name>jms/novaJMSConnectionFactory</res-ref-name>
  |         		 	<res-type>javax.jms.QueueConnectionFactory</res-type>
  |       				<jndi-name>QueueConnectionFactory</jndi-name> 
  |       			</resource-ref> 
  | 			<!-- 	<resource-env-ref>
  | 		        	<resource-env-ref-name>jms/novaJMSConnectionFactory</resource-env-ref-name>
  | 					<jndi-name>QueueConnectionFactory</jndi-name>
  | 			    </resource-env-ref> -->
  | 				
  | 		</message-driven>	
  | 	</enterprise-bean>
  | 
  | 	<security-role-assignment>
  | 		<role-name>admin</role-name>
  | 		<principal-name>server</principal-name>
  | 	</security-role-assignment>
  | </jboss>
  | 

Lastly, my build.xml is as follow.


  | <?xml version="1.0" ?>
  | <project name="nova" default="buildEar">
  | 	<property file="serverbuild.properties" />
  | 	<echo>
  | 	Starting to Build Server. Make sure to change MQ.properties and Persistance.properties 
  | 	</echo>
  | 
  | 	<target name="setupDir">
  | 		<mkdir dir="${dest}" />
  | 		<mkdir dir="${build}" />
  | 		<mkdir dir="${lib}" />
  | 		<mkdir dir="${metainf}" />
  | 	</target>
  | 
  | 	<target name="clean">
  | 		<mkdir dir="${dest}" />
  | 		<delete includeemptydirs="true">
  | 			<fileset dir="${dest}" includes="**/*" />
  | 		</delete>
  | 		<mkdir dir="${build}" />
  | 		<mkdir dir="${lib}" />
  | 		<mkdir dir="${metainf}" />
  | 	</target>
  | 	
  | 	<path id="project.class.path">
  | 		<pathelement location="${code}/lib/cglib-2.1.3.jar" />
  | 		<pathelement location="${code}/lib/colt.jar" />
  | 		<pathelement location="${code}/lib/commons-collections-2.1.1.jar" />
  | 		<pathelement location="${code}/lib/commons-logging-1.0.4.jar" />
  | 		<pathelement location="${code}/lib/concurrent-1.3.2.jar" />
  | 		<pathelement location="${code}/lib/dom4j-1.6.1.jar" />
  | 		<pathelement location="${code}/lib/ehcache-1.1.jar" />
  | 		<pathelement location="${code}/lib/hibernate3.jar" />
  | 		<pathelement location="${code}/lib/jboss-cache.jar" />
  | 		<pathelement location="${code}/lib/jboss-system.jar" />
  | 		<pathelement location="${code}/lib/jboss-jmx.jar" />
  | 		<pathelement location="${code}/lib/jboss-common.jar" />
  | 		<pathelement location="${code}/lib/jboss-minimal.jar" />
  | 		<pathelement location="${code}/lib/jboss-j2ee.jar" />
  | 		<pathelement location="${code}/lib/jgroups-2.2.7.jar" />
  | 		<pathelement location="${code}/lib/log4j-1.2.11.jar" />
  | 		<pathelement location="${code}/lib/odmg-3.0.jar" />
  | 		<pathelement location="${code}/lib/oro.jar" />
  | 		<pathelement location="${code}/lib/protomatter.jar" />
  | 		<pathelement location="${code}/lib/xerces-2.6.2.jar" />
  | 		<pathelement location="${code}/lib/xml-apis.jar" />
  | 		<pathelement location="${code}/lib/djep-full-latest.jar" />
  | 		<pathelement location="${code}/lib/commons-beanutils-bean-collections.jar" />
  | 		<pathelement location="${code}/lib/commons-beanutils-core.jar" />
  | 		<pathelement location="${code}/lib/commons-beanutils.jar" />
  | 		<pathelement location="${code}/lib/JoSQL-1.3.jar" />
  | 		<pathelement location="${code}/lib/gentlyWEB-utils-1.1.jar" />
  | 		<pathelement location="${code}/lib/asm.jar" />
  | 		<pathelement location="${code}/lib/asm-attrs.jar" />
  | 		<pathelement location="${code}/lib/jcommon-0.9.6.jar" />
  | 		<pathelement location="${code}/lib/trove.jar" />
  | 		<pathelement location="${code}/lib/jh.jar" />
  | 		<pathelement location="${code}/lib/jfreechart-0.9.21.jar" />
  | 		<pathelement location="${code}/lib/jintegra.jar" />
  | 		<pathelement location="${code}/lib/junit-3.8.1.jar" />
  | 		<pathelement location="${code}/lib/jdom.jar" />
  | 		<pathelement location="${code}/lib/javax.servlet.jar" />
  | 		<pathelement location="${code}/lib/javax.servlet.jsp.jar" />
  | 		<pathelement location="${code}/lib/jax-qname.jar" />
  | 		<pathelement location="${code}/lib/bcel.jar" />
  | 		<pathelement location="${code}/lib/jnp-client.jar" />
  | <!--		<pathelement location="${code}/lib/jbossall-client.jar" />-->
  | 		<pathelement location="${code}/lib/jbossmq-client.jar" />
  | 		<pathelement location="${code}/lib/jboss-system-client.jar" />
  | 		
  | 		
  | 		<pathelement location="${code}/lib/javax.jms.jar" />
  | 		<pathelement location="${code}/lib/excel2000.jar" />
  | 				
  | 		<!-- Jars for report scheduler utility -->
  | 		<pathelement location="${code}/lib/axis.jar" />		
  | 		<pathelement location="${code}/lib/commons-discovery.jar" />
  | 		<pathelement location="${code}/lib/idapi.jar" />
  | 		<pathelement location="${code}/lib/webservices.jar" />
  | 	</path>
  | 	
  | 	<target name="compile">
  | 		<javac destdir="${build}" fork="true" debug="on" deprecation="on" memoryInitialSize="512m" memoryMaximumSize="1024m">
  | 			<src path="${code}/src" />
  | 			<include name="**/*.java" />
  | 			<exclude name="com/novarum/nova/util/JIntegraServer.java" />
  | 			<exclude name="com/ebw/nova/client/**" />
  | 			<exclude name="com/ssmb/**" />
  | 			<exclude name="com/ebw/nova/common/Batch*.*" />
  | 			<classpath refid="project.class.path" />
  | 		</javac>
  | 		<mkdir dir="${code}/web/AccessControl/WEB-INF/classes" />
  | 		<javac destdir="${code}/web/AccessControl/WEB-INF/classes" debug="on" deprecation="on">
  | 			<src path="${code}/web/AccessControl/WEB-INF/src" />
  | 			<include name="**/*.java" />
  | 			<classpath refid="project.class.path" />
  | 			<classpath>
  | 				<pathelement location="${code}/web/AccessControl/WEB-INF/lib/struts.jar" />
  | 				<pathelement location="${build}" />
  | 			</classpath>
  | 		</javac>
  | 
  | 	</target>
  | 
  | 	<target name="NovaJar">
  | 		<jar destfile="${lib}/nova.jar" basedir="${build}">
  | 			<include name="com/**" />
  | 			<exclude name="**/JIntegraServer.class" />
  | 			<exclude name="com/ebw/ejb/**" />			
  | 			<exclude name="com/novarum/nova/application/client/**" />
  | 			<exclude name="com/novarum/nova/application/Help/**" />
  | 			<exclude name="com/novarum/nova/application/local/**" />
  | 		</jar>
  | 		<jar destfile="${lib}/nova.jar" basedir="${code}/res" update="true" >
  | 			<exclude name="images/**" />
  | 			<exclude name="meta-inf/help/**" />
  | 			<exclude name="reportTrigger/**" />
  | 			<exclude name="properties/**" />
  | 		</jar>	
  | 	</target>
  | 
  | 	<target name="BeanJar">
  | 		<ejbjar srcdir="${build}" descriptordir="${code}/build/descriptors/MQManager" basejarname="novaejb" flatdestdir="true">
  | 			<dtd publicid="-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" location="file:///${code}/build/dtds/ejb-jar_2_0.dtd" />
  | 			<dtd publicid="-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" location="file:///${code}/build/dtds/application_1_3.dtd" />
  | 			<dtd publicId="-//JBoss//DTD JBOSS 4.0//EN" location="../dtd/jboss_4_0.dtd"/> 
  | 			<dtd publicid="-//JBoss//DTD JBOSS 4.0//EN" location="file:///${code}/build/dtds/jboss-app_4_0.dtd" />
  | 			<jboss destdir="${dest}"/>
  | 		</ejbjar>
  | 	</target>
  | 	
  | 	<target name="NovaSar">
  | 			<jar destfile="${dest}/myapp.sar"  basedir="${lib}" >
  | 				<include name="nova.jar"/>
  | 				<!--include name="com/ebw/nova/util/ApplicationStartupMBean.class"/-->
  | 			</jar>
  | 			<jar destfile="${dest}/myapp.sar" basedir="${code}/src" update="true" >
  | 				<include name="META-INF/jboss-service.xml" />
  | 				<exclude name="com/**" />
  | 			</jar>
  | 	</target>
  | 		
  | 	<target name="AccessControlWar">
  | 		<war destfile="${dest}/acl.war" webxml="${code}/web/AccessControl/WEB-INF/web.xml">
  | 			<fileset dir="${code}/web/AccessControl" excludes="${code}/web/AccessControl/WEB-INF/src, **/web.xml, **/MANIFEST.MF" />
  | 		</war>
  | 		
  | 		<!-- Deleting .class files after creating war. -->
  | 		<delete includeemptydirs="true">
  | 			<fileset dir="${code}/web/AccessControl/WEB-INF/classes" includes="**/*" />
  | 		</delete>
  | 	</target>
  | 
  | 	<target name="LibCopy">
  | 		<copy file="${code}/lib/cglib-2.1.3.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/colt.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/commons-collections-2.1.1.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/commons-logging-1.0.4.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/concurrent-1.3.2.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/ehcache-1.1.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jboss-cache.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jboss-system.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jgroups-2.2.7.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jboss-jmx.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jboss-common.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jboss-minimal.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jboss-j2ee.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jax-qname.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/hibernate3.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/odmg-3.0.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/oro.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/protomatter.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jdom.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/dom4j-1.6.1.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/log4j-1.2.11.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/xerces-2.6.2.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/xml-apis.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/vendor.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/asm.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/asm-attrs.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/djep-full-latest.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/commons-beanutils-bean-collections.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/commons-beanutils-core.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/commons-beanutils.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/JoSQL-1.3.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/trove.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/javax.jms.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/bcel.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jnp-client.jar" todir="${lib}" />
  | <!--		<copy file="${code}/lib/jbossall-client.jar" todir="${lib}" />-->
  | 		<copy file="${code}/lib/jbossmq-client.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/jboss-system-client.jar" todir="${lib}" />
  | 		
  | 		<copy file="${code}/lib/gentlyWEB-utils-1.1.jar" todir="${lib}" />
  | 		<copy file="${code}/build/descriptors/application.xml" todir="${metainf}" />
  | 		<copy file="${code}/build/descriptors/jboss-app.xml" todir="${metainf}" />
  | 		
  | 		
  | 
  | 		<!-- Jars for report scheduler utility -->
  | 		<copy file="${code}/lib/axis.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/commons-discovery.jar" todir="${lib}" />
  | 		<copy file="${code}/lib/idapi.jar" todir="${lib}" />
  | 	</target>
  | 
  | 	<target name="buildEarClean" depends="clean,compile,NovaJar,BeanJar,NovaSar,AccessControlWar,LibCopy">
  | 		<delete includeemptydirs="true">
  | 			<fileset dir="${build}" includes="**/*" />
  | 		</delete>
  | 		<jar destfile="${dest}/nova.ear" basedir="${dest}">
  | 			<exclude name="bin/**" />
  | 		</jar>
  | 		<delete includeemptydirs="true">
  | 			<fileset dir="${dest}" includes="**/*" excludes="nova.ear" />
  | 		</delete>
  | 	</target>
  | 
  | 	<target name="buildEar" depends="setupDir,compile,NovaJar,BeanJar,NovaSar,AccessControlWar,LibCopy">
  | 		<jar destfile="${dest}/nova.ear" basedir="${dest}">
  | 			<exclude name="bin/**" />
  | 			<exclude name="nova.ear" />
  | 		</jar>
  | 		<delete includeemptydirs="true">
  | 			<fileset dir="${dest}" includes="**/*">
  | 				<exclude name="bin/**" />
  | 				<exclude name="nova.ear" />
  | 			</fileset>
  | 		</delete>
  | 	</target>
  | 
  | 	<!--  Target to build report scheduler  -->
  | 	<property name="rptFolderName" value="reportTrigger" />
  | 	<property name="rptTrgBase" location="${build}/${rptFolderName}" />
  | 	<target name="buildReportTrigger" depends="setupDir">
  | 		<delete includeemptydirs="true" failonerror="false">
  | 			<fileset dir="${rptTrgBase}" includes="**/*"></fileset>
  | 		</delete>
  | 		<delete includeemptydirs="true">
  | 			<fileset dir="${dest}" includes="reportTrigger.zip"/>
  | 		</delete>
  | 		<mkdir dir="${rptTrgBase}/lib" />
  | 		<mkdir dir="${rptTrgBase}/com/ebw/nova/common" />
  | 		<mkdir dir="${rptTrgBase}/com/novarum/nova/bean" />
  | 		<copy file="${code}/res/reportTrigger/LogMgr.txt"
  | 			tofile="${rptTrgBase}/com/novarum/nova/bean/LogMgr.java" />
  | 		<copy file="${code}/res/reportTrigger/ReportTrigger_MQ.properties"
  | 			tofile="${rptTrgBase}/MQ.properties" />
  | 		<copy todir="${rptTrgBase}/com/ebw/nova/common">
  | 			<fileset dir="${code}/src/com/ebw/nova/common"
  | 				includes="MessagingHelper.java, NovaExtConstant.java, TriggerMessage.java" />
  | 		</copy>
  | 		<copy todir="${rptTrgBase}">
  | 			<fileset dir="${code}/res/reportTrigger" includes="**/*"
  | 				excludes="LogMgr.txt, ReportTrigger_MQ.properties" />
  | 		</copy>
  | 		<javac destdir="${rptTrgBase}"
  | 			classpath="${code}/lib/jbossmq-client.jar:${code}/lib/protomatter.jar">
  | 			<src path="${rptTrgBase}" />
  | 			<include name="**/*.java" />
  | 		</javac>
  | 
  | 		<delete includeemptydirs="true" failonerror="false">
  | 			<fileset dir="${rptTrgBase}" includes="**/*.java" />
  | 		</delete>
  | 		<!--
  | 		<jar destfile="${rptTrgBase}/reportTrigger.jar"
  | 			basedir="${rptTrgBase}">
  | 			<manifest>
  | 				<attribute name="Class-Path" value="wljmsclient.jar" />
  | 				<attribute name="Main-Class"
  | 					value="com.ebw.nova.common.TriggerMessage" />
  | 			</manifest>
  | 		</jar>
  | 		-->
  | 		<copy todir="${rptTrgBase}/lib">
  | 			<fileset dir="${code}/lib/" includes="jbossmq-client.jar, jboss-j2ee.jar"/>
  | 		</copy>
  | 
  | 		<zip destfile="${dest}/reportTrigger.zip" basedir="${rptTrgBase}/.." includes="${rptFolderName}/**/*" />
  | 
  | 		<delete includeemptydirs="true" failonerror="false">
  | 			<fileset dir="${rptTrgBase}" includes="**/*" />
  | 			<fileset dir="${rptTrgBase}/.." includes="${rptFolderName}" />
  | 		</delete>
  | 	</target>
  | 	
  | </project>


Please help. I am struggling to fix it.

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

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



More information about the jboss-user mailing list