Community   SpringSource   Projects    Downloads    Documentation    Forums    Training   Exchange   Blogs

Go Back   Spring Community Forums > Core Spring Projects > Remoting and JMS

Reply
 
Thread Tools Display Modes
  #1  
Old Feb 14th, 2007, 02:35 PM
mbabauer mbabauer is offline
Member
 
Join Date: Feb 2006
Posts: 40
Default Problems injecting the ConnectionFactory and Queue into DefaultMessageListenerContain

I am trying to get a JMS queue to work in JBoss, but I keep getting an error.

I am working off of the example here, but when I start up JBoss I get the following:
Code:
4:26:28,464 INFO  [STDOUT] 14:26:28,459 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listenerContainer' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (2) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.jboss.mq.SpyConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.mq.SpyConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
PropertyAccessException 2: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.jboss.mq.SpyQueue] to required type [javax.jms.Destination] for property 'destination'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.mq.SpyQueue] to required type [javax.jms.Destination] for property 'destination': no matching editors or conversion strategy found
Caused by: 
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (2) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.jboss.mq.SpyConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.mq.SpyConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
...
The AppCtx defining the beans in question look like:
Code:
	<bean id="connectionFactory"
		class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiTemplate">
			<ref bean="jndiTemplate" />
		</property>
		<property name="jndiName">
			<value>UIL2ConnectionFactory</value>
		</property>
	</bean>

	<!-- JMS Destination -->
	<bean id="destination"
		class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiTemplate">
			<ref bean="jndiTemplate" />
		</property>
		<property name="jndiName">
			<value>queue/HashGrabberQueue</value>
		</property>
	</bean>

	<!-- this is the Message Driven POJO (MDP) -->
	<bean id="messageListener" class="com.codechimp.hashgrabber.HashProcessor" />

	<!-- and this is the message listener container -->
	<bean id="listenerContainer"
		class="org.springframework.jms.listener.DefaultMessageListenerContainer102">
		<property name="concurrentConsumers" value="1" />
		<property name="connectionFactory" ref="connectionFactory" />
		<property name="destination" ref="destination" />
		<property name="messageListener" ref="messageListener" />
	</bean>
And the Queue is defined as such:
Code:
<server>
	<!-- Destination without a configured SecurityManager or without a 
		a SecurityConf will default to role guest with read=true, write=true,
		create=false.
	-->
	<mbean code="org.jboss.mq.server.jmx.Queue"
		name="jboss.mq.destination:service=Queue,name=HashGrabberQueue">
		<depends optional-attribute-name="DestinationManager">
			jboss.mq:service=DestinationManager
		</depends>
	</mbean>
</server>
I am not sure what I am doing wrong here, but I would like to understand.

Edit: If someone could just point me in the direction of a better guide for doing JMS in JBoss 4.x using Spring 2.0 that would be awesome.

Edit 2:
I have tried SEVERAL things, and was hoping someone could point me in the right direction by now. Obviously the problem I am having stems from the fact the "ConnectionFactory" I am getting from JNDI is not of the right class type...this I know. What I don't know is how/where to get the right type. So far I have tried the following:
- I changed the JndiObjectFactoryBean to lookup "java:/JmsXA", which identifies itself as class type org.jboss.resource.adapter.jms.JmsConnectionFactor yImpl. This throws the same sort of conversion exception as before.
- I tried copying the Bean setup in a different post that used a org.springframework.jms.connection.SingleConnectio nFactory, but it complains with the same error about conversion.
- I tried looking up all things in JNDI named ConnectionFactory or with ConnectionFactory as part of its classname somewhere, and the only ones I have is either the org.jboss.mq.SpyConnectionFactory, org.jboss.mq.SpyXAConnectionFactory, or org.jboss.resource.adapter.jms.JmsConnectionFactor yImpl. Nothing else seems to identify its class type as a "ConnectionFactory" thats not one of those 3 things.

I am really getting desparate here. I will take any leads anyone can give me, but I honestly feel I have expended all my possibilities up to this point.

Last edited by mbabauer; Feb 16th, 2007 at 05:22 PM.
Reply With Quote
  #2  
Old Feb 17th, 2007, 10:49 AM
Juergen Hoeller Juergen Hoeller is offline
Senior Member
Spring Team
 
Join Date: Aug 2004
Location: Linz, Austria
Posts: 391
Default

This looks like a class loading problem: You seem to have the JMS API jar on your classpath at multiple levels. Make sure that you do not include the JMS API jar in any of your application deployment units; it should only be loaded from the server's bootstrap class loader.

Juergen
Reply With Quote
  #3  
Old Feb 20th, 2007, 09:39 AM
mbabauer mbabauer is offline
Member
 
Join Date: Feb 2006
Posts: 40
Default

Quote:
Originally Posted by Juergen Hoeller View Post
This looks like a class loading problem: You seem to have the JMS API jar on your classpath at multiple levels.
Juergen
That was absolutely it! I was using Maven to build the JARs/WARs, and it was pulling in the JMS stuff automagically. Once I added a dependecy for JMS with a scope of "provided", everything started up like magic!

Thank you, thank you, thank you!
Reply With Quote
  #4  
Old Jun 17th, 2009, 08:12 PM
vamsi06 vamsi06 is offline
Junior Member
 
Join Date: Dec 2007
Posts: 9
Default

Hi,

I have encountered the same exception. i have tried the above solution, removed the jms jar file from my application, but the problem is still there. Any help?

org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.jboss.jms.client.JBossConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.jms.client.JBossConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
Caused by:
java.lang.IllegalArgumentException: Cannot convert value of type [org.jboss.jms.client.JBossConnectionFactory] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:231)
Reply With Quote
  #5  
Old Jun 17th, 2009, 08:50 PM
vamsi06 vamsi06 is offline
Junior Member
 
Join Date: Dec 2007
Posts: 9
Default

Ok. the problem was that I had activemq-all.jar in my classpath. Thanks.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:08 AM.


Contegix provides first-class managed hosting and partial sponsorship of these forums.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.