2015-08-17 87 views
2

我想實現SFTP出站網關,並獲得以下異常。我想在下載到本地目錄後將文件從一個位置移動到其他位置。我是這方面的新人。有人可以幫幫我嗎。提前致謝。SFTP出站網關不工作

ExceptiontraceLog:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.sftp.gateway.SftpOutboundGateway#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.integration.sftp.gateway.SftpOutboundGateway]: Constructor threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1070E:(pos 0): Problem parsing left operand 
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:278) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) 
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) 
    at com.canaldigital.tsi.bank.config.AppMain.main(AppMain.java:32) 
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.integration.sftp.gateway.SftpOutboundGateway]: Constructor threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1070E:(pos 0): Problem parsing left operand 
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164) 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:125) 
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:270) 
    ... 14 more 
Caused by: org.springframework.expression.spel.SpelParseException: EL1070E:(pos 0): Problem parsing left operand 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.raiseInternalException(InternalSpelExpressionParser.java:898) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.checkLeftOperand(InternalSpelExpressionParser.java:916) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.checkOperands(InternalSpelExpressionParser.java:910) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatProductExpression(InternalSpelExpressionParser.java:234) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatSumExpression(InternalSpelExpressionParser.java:213) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatRelationalExpression(InternalSpelExpressionParser.java:168) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatLogicalAndExpression(InternalSpelExpressionParser.java:156) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatLogicalOrExpression(InternalSpelExpressionParser.java:144) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.eatExpression(InternalSpelExpressionParser.java:104) 
    at org.springframework.expression.spel.standard.InternalSpelExpressionParser.doParseExpression(InternalSpelExpressionParser.java:85) 
    at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:56) 
    at org.springframework.expression.spel.standard.SpelExpressionParser.doParseExpression(SpelExpressionParser.java:32) 
    at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:76) 
    at org.springframework.expression.common.TemplateAwareExpressionParser.parseExpression(TemplateAwareExpressionParser.java:62) 
    at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.<init>(AbstractRemoteFileOutboundGateway.java:240) 
    at org.springframework.integration.sftp.gateway.SftpOutboundGateway.<init>(SftpOutboundGateway.java:45) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148) 
    ... 16 more 

的applicationContext.xml

<?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:context="http://www.springframework.org/schema/context" 
    xmlns:task="http://www.springframework.org/schema/task" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:int="http://www.springframework.org/schema/integration" 
    xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-4.0.xsd 
          http://www.springframework.org/schema/tx 
          http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 
          http://www.springframework.org/schema/task 
          http://www.springframework.org/schema/task/spring-task-4.0.xsd       
          http://www.springframework.org/schema/integration 
          http://www.springframework.org/schema/integration/spring-integration.xsd 
          http://www.springframework.org/schema/integration/sftp 
          http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">      


    <context:component-scan base-package="com.canaldigital.tsi.bank" /> 
    <context:property-placeholder location="classpath:settings.properties" /> 

    <bean id="defaultSftpSessionFactory" 
      class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory"> 
     <property name="host" value="${sftp.host}"/> 
     <property name="user" value="${sftp.username}"/> 
    <!-- <property name="password" value="${sftp.password}"/> --> 
     <property name="port" value="${sftp.serverPort}"/> 

     <!-- <property name="privateKey" value="${sftp.private.keyfile}"/> --> 
     <property name="privateKey" value="classpath:IBS_KEYS/id_rsa.txt"/> 

     <property name="privateKeyPassphrase" value="${sftp.passphrase}"/> 

    </bean> 

    <bean id="sftpSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory"> 
     <constructor-arg ref="defaultSftpSessionFactory" /> 
    </bean> 

     <int-sftp:outbound-gateway id="gateway3" 
           session-factory="sftpSessionFactory" 
           request-channel="inbound1" 
           reply-channel="outbound" 
           auto-startup="true" 
           command="mv" 
           expression="/home/oracle/IBSTOBANK/Test/Outgoing/" 
           rename-expression="/home/oracle/IBSTOBANK/Test/Incoming/" /> 


    <int:channel id="inbound1"> 
     <int:queue/> 
    </int:channel> 


<int:channel id="outbound"/> 



</beans> 

回答

1

看起來你應該學習什麼是SpEL,首先。

所以,你的問題就在這裏:

expression="/home/oracle/IBSTOBANK/Test/Outgoing/" 
rename-expression="/home/oracle/IBSTOBANK/Test/Incoming/" 

兩者都不是正確的規劃環境地政司表達式。

從其他方面來看,如果你真的想要原始路徑表示,你應該在那裏使用literal詭計。只需將這些值包裝爲單引號:

expression="'/home/oracle/IBSTOBANK/Test/Outgoing/'" 
rename-expression="'/home/oracle/IBSTOBANK/Test/Incoming/'" 
+0

感謝您的回答。 :) – user3548196