Results 1 to 7 of 7

Thread: input-channel totally ignored in int:service-activator

  1. #1
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Exclamation input-channel totally ignored in int:service-activator

    Hello

    I have the follow

    Code:
    <import resource="classpath:/activemq-configuration.xml" />
    	
    <context:component-scan base-package="com.manuel.jordan.integration" />
    
    <int:channel id="recepcion" />
    		
    <int-jms:message-driven-channel-adapter id="jmsEntrada"
                                                             channel="recepcion"
                                                             connection-factory="connectionFactory"
                                                             destination-name="ordenpedido-usa"
    							 />
    											 
    								 
    <int:service-activator id="recepcionActivator"
                                  ref="recepcionActivator"
                                  method="recepcionHandler"
    input-channel="recepcion"
    	    />
    I have checked my books, Spring Integration Reference documentation and my int:service-activator
    is fine

    The Java class is not complex

    Code:
    package com.manuel.jordan.integration;
    
    import org.springframework.stereotype.Component;
    
    import org.springframework.integration.Message;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    /**
     * 
     * @author Ing Manuel Jordan Elera (dr_pompeii)
     * @version 1.0
     * @since 12/10/2012 
     * 
     */
    @Component
    public class RecepcionActivator {
    
    	private static final Logger logger = LoggerFactory.getLogger(RecepcionActivator.class);
    			
    	public void recepcionHandler(Message<?> message){
    		
    		logger.info("recepcionHandler Message: {}", message.getPayload());
    		
    	}
    			
    }
    But when I execute my Main class I always get this error

    Code:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'recepcionActivator': 
    Cannot resolve reference to bean 'org.springframework.integration.config.ServiceActivatorFactoryBean#0' 
    while setting bean property 'handler'; 
    nested exception is org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#0': 
    Cannot resolve reference to bean 'recepcionActivator' while setting bean property 'targetObject'; 
    nested exception is org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'recepcionActivator': 
    FactoryBean threw exception on object creation; nested exception is 
    java.lang.IllegalStateException: one of inputChannelName or inputChannel is required
    	at
    What is wrong? I have such attribute

    Code:
    <int:service-activator id="recepcionActivator"
                                  ref="recepcionActivator"
                                  method="recepcionHandler"
            input-channel="recepcion"
    	    />
    I am working with

    STS 3.0.0
    Spring Framework 3.1.2.RELEASE
    Spring Integration 2.1.3.RELEASE


    Code:
                    <dependency>
    			<groupId>org.springframework.integration</groupId>
    			<artifactId>spring-integration-core</artifactId>
    			<version>${spring.integration.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.integration</groupId>
    			<artifactId>spring-integration-jms</artifactId>
    			<version>${spring.integration.version}</version>
    		</dependency>
    Thanks in advanced
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Strange, I can't reproduce it in isolation. Can you remove all other moving parts and just do something equivalent to this:
    Code:
    <context:component-scan base-package="org.foo.mypackage"/>
    	
    <int:channel id="inputChannel"/>
    	
    <int:service-activator input-channel="inputChannel" ref="myService" method="foo"/>
    
    @Component
    public class MyService {
    
    	public void foo(Message<?> message){
    
    	}
    }
    And then if it works start adding JMS configuration etc. .

  3. #3
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hi Oleg

    I did remove the jms compoenent and sadly same situation.

    BTW I forgot indicate that I am working with the Spring Integration Project (Standalone) - Simple.

    Some ideas?

    A bug from the Template itself in some way?.
    I will test in a other type of template too see what happen

    It is weird
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    The code that I posted is pretty much what you have and what I tested and everything is fine so I wanted you to do te same so we can figure out where the problem is

  5. #5
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hi Oleg

    I just did the follow (STS 3.0.0 + Java 7 Update 07)

    1) Create a Spring Integration Project (Standalone) - Simple.

    2) Add

    Code:
        <spring.framework.version>3.1.2.RELEASE</spring.framework.version>
        <apache.activemq.version>5.6.0</apache.activemq.version>
        <slf4j.version>1.7.2</slf4j.version>
    3) Update

    From

    Code:
     <spring.integration.version>2.1.2.RELEASE</spring.integration.version>
    To

    Code:
    <spring.integration.version>2.1.3.RELEASE</spring.integration.version>

    4) Add among many dependencies, these two

    Code:
     
    
                      <!-- Spring JMS -->
    
                     <dependency>
    			<groupId>org.springframework.integration</groupId>
    			<artifactId>spring-integration-core</artifactId>
    			<version>${spring.integration.version}</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework.integration</groupId>
    			<artifactId>spring-integration-jms</artifactId>
    			<version>${spring.integration.version}</version>
    		</dependency>
    And comment the follow maven dependency already created by the template itself

    Code:
       
                     <dependency>
    			<groupId>org.springframework.integration</groupId>
    			<artifactId>spring-integration-core</artifactId>
    			<version>${spring.integration.version}</version>
    		</dependency>
    Otherwise since I have the same dependency declared twice I got

    Code:
    Caused by: java.lang.NoSuchFieldError: NULL
    	at org.springframework.expression.TypedValue.<clinit>(TypedValue.java:32)
    	at org.springframework.expression.spel.support.StandardEvaluationContext.setRootObject(StandardEvaluationContext.java:88)
    5) Create activemq-configuration.xml in src/main/resources, it only contains

    Code:
    <bean id="connectionFactory"
            class="org.apache.activemq.ActiveMQConnectionFactory" >
          <property name="brokerURL" value="tcp://localhost:61616"/>
    </bean>
    6) Create my Java class

    Code:
    package com.manuel.jordan.integration;
    
    import org.springframework.stereotype.Component;
    
    import org.springframework.integration.Message;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    /**
     * 
     * @author Ing Manuel Jordan Elera (dr_pompeii)
     * @version 1.0
     * @since 12/10/2012 
     * 
     */
    @Component
    public class RecepcionActivator {
    
    	private static final Logger logger = LoggerFactory.getLogger(RecepcionActivator.class);
    			
    	public void recepcionHandler(Message<?> message){
    		
    		logger.info("recepcionHandler Message: {}", message.getPayload());
    		
    	}
    			
    }
    7) Create my spring-integration-recepcion.xml in src/main/resources, it contains now

    Code:
            <import resource="classpath:/activemq-configuration.xml" />
    		 
    	<context:component-scan base-package="com.manuel.jordan.integration" />
    	
    	
    	<int:channel id="recepcion" />
    	
    	<!-- 	
    	<int-jms:message-driven-channel-adapter id="jmsEntrada"
    										    channel="recepcion"
    										    connection-factory="connectionFactory"
    										    destination-name="ordenpedido-usa"
    											 />
    		 -->									 
    								 
    	<int:service-activator id="recepcionActivator"						   
    						   ref="recepcionActivator"
    						   method="recepcionHandler"
    						   input-channel="recepcion"
    						    />
    8) Finally the Main class

    Code:
    public class Main {
    
    	private static final Logger logger = LoggerFactory.getLogger(Main.class);
    	
    	public static void main(String[] args) {
    
    		logger.info("main method");
    
    		final Scanner scanner = new Scanner(System.in);
    		
    		ClassPathXmlApplicationContext context = 
    				new ClassPathXmlApplicationContext("classpath:/spring-integration-recepcion.xml");		
    		
    		context.start();
    		
    		while(true){
    			
    			final String input = scanner.nextLine();
    			
    			if("q".equals(input.trim())) {
    				break;
    			}
    		}
    		
    		scanner.close();
    		context.stop();
    		context.close();
    	}
    And when I execute my Main class I got

    Code:
    Caused by: java.lang.IllegalStateException: one of inputChannelName or inputChannel is required
    	at org.springframework.util.Assert.state(Assert.java:384)
    	at org.springframework.integration.config.ConsumerEndpointFactoryBean.initializeEndpoint(ConsumerEndpointFactoryBean.java:170)
    	at org.springframework.integration.config.ConsumerEndpointFactoryBean.getObject(ConsumerEndpointFactoryBean.java:144)
    	at org.springframework.integration.config.ConsumerEndpointFactoryBean.getObject(ConsumerEndpointFactoryBean.java:49)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
    	... 30 more
    Could you do the same in your own side?

    Thank you
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  6. #6
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Did you do what I asked you? - run just the configuration i posted before. I am trying to eliminate all the irrelevant parts (e.g., JMS, ActiveMQ etc). Basically cut it down to a bare minimum and IF it works start adding pieces

  7. #7
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Oleg

    The error was mime and was silly, the id and ref attributes are the same.

    Code:
    <int:service-activator        id="recepcionActivator"						   
    			      ref="recepcionActivator"
     			      method="recepcionHandler"
    			      input-channel="recepcion"
    />
    Even when was a silly mistake the container gave me a not very useful error message.

    All work fine now.
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

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