Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: cannot instantiate message-driven-channel-adapter

  1. #1
    Join Date
    May 2011
    Posts
    10

    Default cannot instantiate message-driven-channel-adapter

    I am receiving the follow stack when i attempt to start my spring container:

    Code:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.jms.ChannelPublishingJmsMessageListener#0': Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:900)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:455)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    	at dpz.objectfactory.SpringObjectFactory.<init>(SpringObjectFactory.java:18)
    	at dpz.estore.ordercore.Main.main(Main.java:10)
    I am trying to wire it with the following config:

    Code:
    	<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    		<property name="brokerURL">
    			<value>tcp://localhost:61616</value>
    		</property>
    	</bean>
    	
    	<bean id="defaultMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    		<property name="concurrentConsumers" value="1"/>
    		<property name="connectionFactory" ref="connectionFactory"/>
    		<property name="destinationName" value="exampleQueue"/>
    	</bean>	
    	
    	<integration:channel id="exampleChannel" />
    	
    	<jms:message-driven-channel-adapter id="jmsIn" container="defaultMessageListenerContainer" channel="exampleChannel"/>
    	
    	<integration:chain input-channel="exampleChannel">
    	
    		<integration:transformer method="transform">
    			<bean class="dpz.estore.ordercore.parser.OrderTransformer" />
    		</integration:transformer>
    		
    		<integration:service-activator method="create" ref="orderManager" />
    		
    	</integration:chain>
    I have also used this one to no avail:

    Code:
    	<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    		<property name="brokerURL">
    			<value>tcp://localhost:61616</value>
    		</property>
    	</bean>
    	
    	<integration:channel id="exampleChannel" />
    	
    	<jms:message-driven-channel-adapter id="jmsIn" destination-name="exampleQueue" channel="exampleChannel"/>
    	
    	<integration:chain input-channel="exampleChannel">
    	
    		<integration:transformer method="transform">
    			<bean class="dpz.estore.ordercore.parser.OrderTransformer" />
    		</integration:transformer>
    		
    		<integration:service-activator method="create" ref="orderManager" />
    		
    	</integration:chain>
    This is my first attempt to use spring-integration and I feel a little overwhelmed. Any help would really be appreciated!

  2. #2
    Join Date
    May 2011
    Location
    Oslo
    Posts
    12

    Default

    Hi,

    Did you compare your configuration with jms sample application - http://git.springsource.org/spring-i...ster/basic/jms ?
    Please attach a source code for your project. That will be faster to figure out what's the problem.

    Krzysiek

  3. #3
    Join Date
    May 2011
    Posts
    10

    Default

    The main difference I see between my application and the sample is that I am using the new schema/libs:
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:integration="http://www.springframework.org/schema/integration"
    	xmlns:file="http://www.springframework.org/schema/integration/file"
    	xmlns:jms="http://www.springframework.org/schema/integration/jms"
    	xmlns:mail="http://www.springframework.org/schema/integration/mail"
    	xmlns:rmi="http://www.springframework.org/schema/integration/rmi"
    	xmlns:ws="http://www.springframework.org/schema/integration/ws"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    			http://www.springframework.org/schema/integration
    			http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
    			http://www.springframework.org/schema/integration/file
    			http://www.springframework.org/schema/integration/file/spring-integration-file-2.0.xsd
    			http://www.springframework.org/schema/integration/jms
    			http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.0.xsd
    			http://www.springframework.org/schema/integration/mail
    			http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.xsd
    			http://www.springframework.org/schema/integration/rmi
    			http://www.springframework.org/schema/integration/rmi/spring-integration-rmi-2.0.xsd
    			http://www.springframework.org/schema/integration/ws
    			http://www.springframework.org/schema/integration/ws/spring-integration-ws-2.0.xsd">
    Copying over the wiring from the sample also produces the same exception:
    Code:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.jms.ChannelPublishingJmsMessageListener#0': Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:900)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:455)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
    	at dpz.estore.ordercore.Main.main(Main.java:37)
    Caused by: java.lang.reflect.MalformedParameterizedTypeException
    	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:42)
    	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:35)
    	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:77)
    	at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:86)
    	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:122)
    	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
    	at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:82)
    	at java.lang.Class.getGenericInterfaces(Class.java:794)
    	at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:258)
    	at org.springframework.core.GenericTypeResolver.resolveParameterType(GenericTypeResolver.java:82)
    	at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getWriteMethodParameter(GenericTypeAwarePropertyDescriptor.java:147)
    	at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:129)
    	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:506)
    	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:500)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    There really is no code involved; its just the wiring of the message-driven-channel-adapter that is causing the problem.

    Thank you so much for replying.

  4. #4
    Join Date
    May 2011
    Posts
    10

    Default

    Maybe its helpful to know that this is the dependency entry in my pom.xml for spring-integration:
    Code:
    		<!-- 
    			Spring integration
    		-->
    		<dependency>
    			<groupId>org.springframework.integration</groupId>
    			<artifactId>spring-integration-jms</artifactId>
    			<version>2.0.4.RELEASE</version>
    		</dependency>

  5. #5
    Join Date
    May 2011
    Location
    Oslo
    Posts
    12

    Default

    I am not able to reproduce your error. For me your configuration is working also with the version 2.0.4.
    I know that it's obvious but did you try 'mvn clean install' and run your project again?

    I took your configuration and I created sample test class for it. Run TestInitialization.java in project jms.zip.

    Krzysiek

  6. #6
    Join Date
    May 2011
    Posts
    10

    Default

    Thanks Krzysiek,

    Can you tell me what version of Spring you are importing? I am using 3.1.0.M1

  7. #7

    Default

    Since I just started researching SI JMS, I grabbed this test zip and ran the test class TestInitialization.java. The output I had was not an exception, and I assume this means it worked.

    Profit!
    WARN : org.springframework.jms.listener.DefaultMessageLis tenerContainer - Could not refresh JMS Connection for destination 'exampleQueue' - retrying in 5000 ms. Cause: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect

  8. #8
    Join Date
    May 2011
    Posts
    10

    Default

    Same here... trying to determine what is different in my setup.

  9. #9
    Join Date
    May 2011
    Posts
    10

    Default

    Got it!

    It was this import:

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jms</artifactId>
    <version>2.5.6</version>
    </dependency>

    I had accidentally left it in my pom.xml!

    Thank you guys so very very much!

  10. #10
    Join Date
    May 2011
    Location
    Oslo
    Posts
    12

    Default

    Quote Originally Posted by MacFlecknoe View Post
    Thanks Krzysiek,

    Can you tell me what version of Spring you are importing? I am using 3.1.0.M1
    This example doesn't need this dependency. You can check pom.xml. Usually the best solution is to use latest stable version

    Krzysiek

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •