Java Apache FTP Server import libraries

145 Views Asked by At

I am getting this error while starting the server.

java.lang.NoSuchMethodError: No virtual method supportedOptions()Ljava/util/Set; in class Ljava/nio/channels/ServerSocketChannel; or its super classes (declaration of 'java.nio.channels.ServerSocketChannel' appears in /system/framework/core-libart.jar)
            at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:259)
            at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:52)
            at org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.registerHandles(AbstractPollingIoAcceptor.java:591)
            at org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.run(AbstractPollingIoAcceptor.java:460)
            at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
            at java.lang.Thread.run(Thread.java:833)

Import Libraries are...

    implementation 'org.apache.mina:mina-core:2.1.6'
    implementation 'org.slf4j:slf4j-api:2.0.6'
    implementation 'org.slf4j:slf4j-simple:2.0.6'
    implementation 'org.apache.ftpserver:ftplet-api:1.2.0'
    implementation 'org.apache.ftpserver:ftpserver-core:1.2.0'
2

There are 2 best solutions below

0
Alessio Lai On

Hello this method is supported since one specific version of the api. I I remember well, since api 20, and in jdk this method there is since jdk 1.7. To resolve I have used an earlier version of apache mina, that is compliant with a version earlier of jdk 1.7, because this method wasn't available in jdk before 1.7. Then I have replaced the library with dependencies with the older version and the project started to work and the error not raising again.

Alessio

0
ShaRy On

Yes, that was the issue...Lib version.
Anyway, I have used this combination and it worked for me.

implementation 'log4j:log4j:1.2.17'
implementation 'org.slf4j:slf4j-api:2.0.6'
implementation 'org.slf4j:slf4j-log4j12:1.7.21'
implementation 'org.apache.mina:mina-core:2.1.3'
implementation 'org.apache.ftpserver:ftplet-api:1.1.2'
implementation 'org.apache.ftpserver:ftpserver-core:1.1.2'