在 Tomcat 中嵌入 Apache FTPServer (Mina)
Embed the Apache FTPServer (Mina) in Tomcat
我正在尝试 运行 我的网络应用程序中的 FTP 服务器。
我从这里开始:
http://mina.apache.org/ftpserver-project/embedding_ftpserver.html
并将其放入我的 FOM:
<dependency>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftpserver-core</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftplet-api</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>3.0.0-M2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.18</version>
</dependency>
但是在启动我的 Tomcat 时出现了这个错误:
Mar 11, 2016 2:49:30 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Mar 11, 2016 2:49:30 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/sagitarii] startup failed due to previous errors
...我的应用程序停止了。
我做错了什么?
正如我在评论中所说,class org/apache/mina/filter/executor/OrderedThreadPoolExecutor
不在 3.0 M2 中,我找不到任何示例代码来替换我找到的代码:
PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
UserManager userManager = userManagerFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("cache");
user.setPassword("cache");
user.setHomeDirectory( PathFinder.getInstance().getPath() + "/cache/" );
userManager.save(user);
BaseUser scientist = new BaseUser();
scientist.setName("storage");
scientist.setPassword("storage");
scientist.setHomeDirectory( PathFinder.getInstance().getPath() + "/storage/" );
userManager.save(scientist);
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort( serverPort );
FtpServerFactory factory = new FtpServerFactory(); // <<-- ERROR HERE !!
factory.setUserManager(userManager);
factory.addListener("default", listenerFactory.createListener());
server = factory.createServer();
server.start();
更改为 2.0.13 并开始工作。
我正在尝试 运行 我的网络应用程序中的 FTP 服务器。
我从这里开始:
http://mina.apache.org/ftpserver-project/embedding_ftpserver.html
并将其放入我的 FOM:
<dependency>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftpserver-core</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftplet-api</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>3.0.0-M2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.18</version>
</dependency>
但是在启动我的 Tomcat 时出现了这个错误:
Mar 11, 2016 2:49:30 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Mar 11, 2016 2:49:30 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/sagitarii] startup failed due to previous errors
...我的应用程序停止了。
我做错了什么?
正如我在评论中所说,class org/apache/mina/filter/executor/OrderedThreadPoolExecutor
不在 3.0 M2 中,我找不到任何示例代码来替换我找到的代码:
PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
UserManager userManager = userManagerFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("cache");
user.setPassword("cache");
user.setHomeDirectory( PathFinder.getInstance().getPath() + "/cache/" );
userManager.save(user);
BaseUser scientist = new BaseUser();
scientist.setName("storage");
scientist.setPassword("storage");
scientist.setHomeDirectory( PathFinder.getInstance().getPath() + "/storage/" );
userManager.save(scientist);
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort( serverPort );
FtpServerFactory factory = new FtpServerFactory(); // <<-- ERROR HERE !!
factory.setUserManager(userManager);
factory.addListener("default", listenerFactory.createListener());
server = factory.createServer();
server.start();
更改为 2.0.13 并开始工作。