FTP from Java in Mendix app

0
Hi all, I've been trying to access an FTP server using Java and the ftp4j library, but I run into a problem almost instantly... When in the Java code I want to create a new FTPClient() I get an 'AccessDenied' error of the type 'PropertyPermission. Does anyone know what causes this, and more importantly, how to solve this? The code itself isn't rocket-science, so I was quite confused why it didn't work. Did I miss something? Code where exception occurs: FTPClient client = new FTPClient(); Error: access denied ("java.util.PropertyPermission" "ftp4j.passiveDataTransfer.useSuggestedAddress" "read") Full stacktrace: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "ftp4j.passiveDataTransfer.useSuggestedAddress" "read") at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPropertyAccess(Unknown Source) at java.lang.System.getProperty(Unknown Source) at it.sauronsoftware.ftp4j.FTPConnector.<init>(FTPConnector.java:80) at it.sauronsoftware.ftp4j.FTPConnector.<init>(FTPConnector.java:97) at it.sauronsoftware.ftp4j.connectors.DirectConnector.<init>(DirectConnector.java:35) at it.sauronsoftware.ftp4j.FTPClient.<init>(FTPClient.java:173) at sftp.helpers.FTP.execute(FTP.java:55) at sftp.actions.JA_GetFileList.executeAction(JA_GetFileList.java:55) at sftp.actions.JA_GetFileList.executeAction(JA_GetFileList.java:1) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.hx.execute(SourceFile:42) at com.mendix.ig.a(SourceFile:47) at com.mendix.if.a(SourceFile:193) at com.mendix.if.executeAction(SourceFile:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.executeSync(SourceFile:235) at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SourceFile:33) at com.mendix.ig.a(SourceFile:47) at com.mendix.if.a(SourceFile:193) at com.mendix.if.executeAction(SourceFile:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.iS.a(SourceFile:135) at com.mendix.pf$g.apply$mcV$sp(SourceFile:292) at com.mendix.pf$g.apply(SourceFile:283) at com.mendix.pf$g.apply(SourceFile:283) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(SourceFile:155) at scala.util.Try$.apply(Try.scala:191) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:153) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(SourceFile:146) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) Edited with different stacktraces. With and without emulate cloud security * Emulate Cloud Security On* java.security.AccessControlException: access denied ("java.util.PropertyPermission" "ftp4j.passiveDataTransfer.useSuggestedAddress" "read") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372) at java.security.AccessController.checkPermission(AccessController.java:559) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1298) at java.lang.System.getProperty(System.java:708) at it.sauronsoftware.ftp4j.FTPConnector.<init>(FTPConnector.java:80) at it.sauronsoftware.ftp4j.FTPConnector.<init>(FTPConnector.java:97) at it.sauronsoftware.ftp4j.connectors.DirectConnector.<init>(DirectConnector.java:35) at it.sauronsoftware.ftp4j.FTPClient.<init>(FTPClient.java:173) at sftp.helpers.FTP.execute(FTP.java:55) at sftp.actions.JA_GetFileList.executeAction(JA_GetFileList.java:55) at sftp.actions.JA_GetFileList.executeAction(JA_GetFileList.java:1) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.hx.execute(SourceFile:42) at com.mendix.ig.a(SourceFile:47) at com.mendix.if.a(SourceFile:193) at com.mendix.if.executeAction(SourceFile:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.executeSync(SourceFile:235) at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SourceFile:33) at com.mendix.ig.a(SourceFile:47) at com.mendix.if.a(SourceFile:193) at com.mendix.if.executeAction(SourceFile:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.iS.a(SourceFile:135) at com.mendix.pf$g.apply$mcV$sp(SourceFile:292) at com.mendix.pf$g.apply(SourceFile:283) at com.mendix.pf$g.apply(SourceFile:283) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(SourceFile:155) at scala.util.Try$.apply(Try.scala:191) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:153) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(SourceFile:146) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) *Emulate Cloud Security Off* I seem to get further ( I get a Client Not Connected error), but cannot debug from Eclipse, since that would cause the same error as before.
asked
2 answers
2

I have used all types of FTP (FTP/FTPS/SFTP) successfully in the cloud so it is doable right now. But it does depend on the libraries you are using.

Based on the error message I am assuming you are currently trying to get ftp4j to work in your project? I have never used ftp4j myself. Since you are getting a security error it would require additional privileges. You can always enter a ticket and ask for the additional permissions and our team will evaluate if that could be enabled for all cloud nodes.

I have been using the FTP client from apache (org.apache.commons.net.ftp.FTPClient), which is part of the apache commons.net library. This works fine for me for both FTP and FTPS. For SFTP I use the jsch library (which is also used in the appstore module).

Here you can download an example of the code that i have been using

answered
0

Does this problem occur locally? If yes, you can try to turn 'emulate cloud security' off.

answered