我无法让FTP使用Spring Integration工作

时间:2013-03-28 14:20:17

标签: ftp spring-integration

我正在尝试使用Spring Integration(版本2.2.0.RELEASE)设置我的应用程序以接收文件。 当我启动Tomcat(部署应用程序)时,我收到以下错误消息。任何人都知道为什么?

SEVERE: Error configuring application listener of class com.xxxx.aaa.web.mvc.context.CccccContextListener
java.lang.NoClassDefFoundError: com/xxxx/bbb/application/core/exception/unchecked/InvalidFormatException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.newInstance0(Class.java:326)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4079)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
    at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.xxxx.bbb.application.core.exception.unchecked.InvalidFormatException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
    ... 20 more

我相信上面的错误信息是红鲱鱼。在将spring集成依赖项添加到pom文件并使用ftp配置文件之前,Tomcat已成功启动。

我使用Java6和Tomcat6。我的FTP配置文件是:

<?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="http://www.springframework.org/schema/integration"
    xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
    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.2.xsd
           http://www.springframework.org/schema/integration/ftp
           http://www.springframework.org/schema/integration/ftp/spring-integration-ftp-2.2.xsd">

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

    <bean id="ftpClientFactory"
        class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
        <property name="host" value="localhost" />
        <property name="port" value="21" />
        <property name="username" value="user" />
        <property name="password" value="password" />
    </bean>

    <int-ftp:inbound-channel-adapter 
        id="ftpInbound"
        channel="ftpChannel" 
        filename-pattern="*.csv" 
        session-factory="ftpClientFactory"
        auto-create-local-directory="true" 
        delete-remote-files="true"
        remote-directory="/" 
        local-directory="C:/folder/IN">
            <int:poller fixed-rate="1000" max-messages-per-poll="15"/>
    </int-ftp:inbound-channel-adapter>

</beans>

我在pom文件中添加了依赖项,如下所示:

<dependency>
   <groupId>org.springframework.integration</groupId>
   <artifactId>spring-integration-ftp</artifactId>
   <version>2.2.0.RELEASE</version>
</dependency>

1 个答案:

答案 0 :(得分:2)

实际上,Spring Integration至少需要Spring核心版本3.0.5,而我将其设置为3.0.2。一旦我将spring core升级到3.0.5,就可以了。