Results 1 to 5 of 5

Thread: Can`t create bean of FtpOutboundGateway

  1. #1

    Default Can`t create bean of FtpOutboundGateway

    Hi,
    I am using SI 2.2.0 now but I had the same problem with 2.1.0. I would like to use int-ftp:outbound-gateway but every time I define it I get the following exception.
    So far I just want to define gateway (without use):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
    	xmlns:int="http://www.springframework.org/schema/integration"
    	xsi:schemaLocation="
    	http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd 
    	http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
    	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    	
    	<bean id="ftpSessionFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    		<property name="host" value="foo"/>
    		<property name="port" value="123"/>
    		<property name="username" value="foo"/>
    		<property name="password" value="foo"/>
    	</bean>
    
    	<int:channel id="ftpTransChannel">
    		<int:queue />
    	</int:channel>
    
    	<int-ftp:outbound-gateway 
    		id="outGateway"
    		command="ls"
    		expression="/path/"
    		session-factory="ftpSessionFactory"
    		request-channel="ftpTransChannel"/>
    </beans>

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.ftp.gateway.FtpOutboundGateway#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.integration.ftp.gateway.FtpOutboundGateway]: Constructor threw exception; nested exception is java.lang.NullPointerException
    I had of course more complex functionality but once I got this exception I reduced it to this basic form but the exception is still there. Do you have any idea what can cause the problem?


    ---------------------------------
    My second question is - can be int-ftp:outbound-gateway triggered simply via sending Message into ftpTransChannel (lets say in service-activator)?

    Code:
    Message<String> msg = MessageBuilder.withPayload("/").build();
    ftpTransChannel.send(msg);
    Thank you,
    Jakub

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,146

    Default

    The SpEL expression is not well-formed (but it probably should not result in a NPE; I opened a ticket in Spring https://jira.springsource.org/browse/SPR-10146).

    If you want to use a literal expression, surround it in single quotes
    Code:
    "'/path/'"
    .

    Yes, you can send a message to the gateway but you will need something to consume the result.

    However, it is better to not expose your application to the messaging infrastructure - take a look at the ftp sample - it used a <gateway/>.
    Last edited by Gary Russell; Jan 4th, 2013 at 10:08 AM.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3

    Default

    Thank you Gary.
    Surrounding by single quotes helped to solve mentioned exception but next run thrown another exception:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'outGateway': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No poller has been defined for endpoint 'outGateway', and no default poller is available within the context.
    Which is relay strange in outbound-gateway (I would expect it in case of adapter but not gateway).
    My actual version is SI 2.1.0. The code is still the same (I will add consumer later).

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
    	xmlns:int="http://www.springframework.org/schema/integration"
    	xsi:schemaLocation="
    	http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd 
    	http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
    	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    	
    	
    	<bean id="ftpSessionFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    		<property name="host" value="foo"/>
    		<property name="port" value="123"/>
    		<property name="username" value="foo"/>
    		<property name="password" value="foo"/>
    	</bean>
    
    	<int:channel id="ftpTransChannel">
    		<int:queue />
    	</int:channel>
    
    	<int-ftp:outbound-gateway 
    		id="outGateway"
    		command="ls"
    		expression="'/path/'"
    		session-factory="ftpSessionFactory"
    		request-channel="ftpTransChannel"/>
    </beans>
    Thank you,
    Jakub

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,146

    Default

    Right, because ftpTransChannel is a queue channel, message senders simply drop the message into the queue; we need a thread (poller) to poll the queue and send it to the gateway.

    You can either add a <poller/> element to the gateway, or simply remove the <queue/> element from the channel and the gateway will be invoked on the calling thread.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  5. #5

    Default

    Oh beginner error! It helped -Thank you Garry.

    regards,
    Jakub

Tags for this Thread

Posting Permissions

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