On Wed, Jun 9, 2010 at 3:03 PM, Albert Visagie <[email protected]> wrote:
>> The following simple program, successfully serves up an ftp site. If
>> started again, it logs that the FtpServer has started. My eclipse debugger
>> shows that the acceptor thread has started. The first one still works, as
>> expected. The second just sits there forever.
What OS is this on? I just ran the code on OS X and the second process
outputs the following and then exits:
[] [] [] File configured, will try loading
[] [] [] File found on file system
[] [] [] Intializing shared thread pool executor with max threads of 10
Exception in thread "main"
org.apache.ftpserver.FtpServerConfigurationException: Failed to bind
to address 0.0.0.0/0.0.0.0:2121, check configuration
at
org.apache.ftpserver.listener.nio.NioListener.start(NioListener.java:173)
at
org.apache.ftpserver.impl.DefaultFtpServer.start(DefaultFtpServer.java:80)
at SimpleFtpServer.main(SimpleFtpServer.java:25)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind(Native Method)
at
sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at
org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:251)
at
org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:48)
at
org.apache.mina.core.polling.AbstractPollingIoAcceptor.registerHandles(AbstractPollingIoAcceptor.java:523)
at
org.apache.mina.core.polling.AbstractPollingIoAcceptor.access$200(AbstractPollingIoAcceptor.java:65)
at
org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.run(AbstractPollingIoAcceptor.java:407)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:637)
One reason for this could be the inconsistent handling of socket reuse
on different OSes. FtpServer currently always enables reuse (which
might be why your second server starts but doesn't get any traffic).
We've discussed making this configurable, perhaps we should now
actually do that :-)
/niklas