Announcement Announcement Module
Collapse
No announcement yet.
Problems injecting the ConnectionFactory and Queue into DefaultMessageListenerContain Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 05:22 PM.

  • #2
    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

    Comment


    • #3
      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!

      Comment


      • #4
        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)

        Comment


        • #5
          Ok. the problem was that I had activemq-all.jar in my classpath. Thanks.

          Comment


          • #6
            Hi, I am facing the same problem. There is neither JMS jar nor activemq-all.jar in the classpath. But still getting the below exception. Please help.

            org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jmsTransactionManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is 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

            Comment


            • #7
              Jms classLoader problem

              Hi,
              The problem is that jboss includes jms in jboss-j2ee.jar. If you are using maven just change the scope of jms dependecy to provided.

              regards,
              carlos

              Comment


              • #8
                Hi ,
                i am also getting same kind of error .

                ConversionNotSupportedException: Failed to convert property value of type 'javax.naming.Reference' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [javax.naming.Reference] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
                at org.springframework.beans.BeanWrapperImpl.convertF orProperty(BeanWrapperImpl.java:471)

                Any pointers for this please.

                Thanks,
                Rajesh

                Comment


                • #9
                  Hi,

                  I got the same problem with JONAS 5 and Mq series.
                  I removed all jms jar file dependency but i still got:
                  java.lang.IllegalStateException: Cannot convert value of type [com.ibm.mq.connector.inbound.ActivationSpecImpl] to required type [javax.jms.Destination] for property 'destination': no matching editors or conversion strategy found

                  Thanks,

                  Comment


                  • #10
                    I have strange problem. I am using server JBOSS 5 and in my Spring web application i have to use MQ JARS for creating the connection factory and do the message communication.
                    issue: I am adding MQ jars in to my class path and tried to send a message to MQ. but it is giving an exception classNotFound "com/ibm/mq/jms/MQQueueConnectinFactory". So i have tried to inject the class through spring application context. but it is giving build error.
                    now i have added those JARs to JBOSS server/default/lib folder and it started working locally. Now when i copied the same jars in environment and deployed in Environment, again it is giving me classNotFound exception.
                    Please provide me if anybody have suggestions.

                    Comment

                    Working...
                    X