Java File Permission

0
HI Can any one help me with this permission exception i have tried using the following but still get the same error String path = Core.getFileDocumentContentAsFile(this.getContext(),this.inFile.getMendixObject()).toString(); new FilePermission(path, "read"); An error has occurred while handling the request. [User 'Anonymous_db09ea15-c7d7-4b80-b02a-d5c837e478e0' with roles 'Administrator'] -------- kZ: com.mendix.core.CoreRuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission SkillsMap1.doc read) at {} at MyFirstModule.convert (JavaAction : 'Call 'JA_ConvertToPDF'') Advanced stacktrace: at mf.a(SourceFile:188) Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission SkillsMap1.doc read) at com.mendix.core.Core.execute(SourceFile:225) Caused by: com.mendix.core.CoreRuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission SkillsMap1.doc read) at hC.b(SourceFile:193) Caused by: java.security.AccessControlException: access denied (java.io.FilePermission SkillsMap1.doc read) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkRead(SecurityManager.java:871) at java.io.FileInputStream.<init>(FileInputStream.java:113) at myfirstmodule.actions.JA_ConvertToPDF.executeAction(JA_ConvertToPDF.java:52) at myfirstmodule.actions.JA_ConvertToPDF.executeAction(JA_ConvertToPDF.java:1) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:182) at com.mendix.core.Core.execute(SourceFile:219) at lg.a(SourceFile:70) at mf.a(SourceFile:73) at me.executeAction(SourceFile:101) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:182) at com.mendix.core.Core.execute(SourceFile:219) at gm.execute(SourceFile:186) at iW.a(SourceFile:285) at ja$g.a(SourceFile:126) at ja$g$a.a(SourceFile:118) at ja$g$a.apply(SourceFile:116) at akka.actor.Actor$class.apply(Actor.scala:545) at ja$g.apply(SourceFile:112) at akka.actor.LocalActorRef.invoke(ActorRef.scala:910) at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123) at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:195) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:123) 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:662) at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192) An error has occurred while handling the request. [User 'Anonymous_db09ea15-c7d7-4b80-b02a-d5c837e478e0' with roles 'Administrator'] -------- kZ: com.mendix.core.CoreRuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission SkillsMap1.doc read) at {} at MyFirstModule.convert (JavaAction : 'Call 'JA_ConvertToPDF'') Advanced stacktrace: at mf.a(SourceFile:188) Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission SkillsMap1.doc read) at com.mendix.core.Core.execute(SourceFile:225) Caused by: com.mendix.core.CoreRuntimeException: java.security.AccessControlException: access denied (java.io.FilePermission SkillsMap1.doc read) at hC.b(SourceFile:193) Caused by: java.security.AccessControlException: access denied (java.io.FilePermission SkillsMap1.doc read) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkRead(SecurityManager.java:871) at java.io.FileInputStream.<init>(FileInputStream.java:113) at myfirstmodule.actions.JA_ConvertToPDF.executeAction(JA_ConvertToPDF.java:52) at myfirstmodule.actions.JA_ConvertToPDF.executeAction(JA_ConvertToPDF.java:1) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:182) at com.mendix.core.Core.execute(SourceFile:219) at lg.a(SourceFile:70) at mf.a(SourceFile:73) at me.executeAction(SourceFile:101) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:182) at com.mendix.core.Core.execute(SourceFile:219) at gm.execute(SourceFile:186) at iW.a(SourceFile:285) at ja$g.a(SourceFile:126) at ja$g$a.a(SourceFile:118) at ja$g$a.apply(SourceFile:116) at akka.actor.Actor$class.apply(Actor.scala:545) at ja$g.apply(SourceFile:112) at akka.actor.LocalActorRef.invoke(ActorRef.scala:910) at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123) at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:195) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:123) 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:662) at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192)
asked
1 answers
0

It is not generally recommended to access files directly. You can get contents of files via

Core.getFileDocumentContent

which returns an InputStream. If you really need a file, I would recommend copying that InputStream to a Temporary File that you can then pass to whatever library you're using.

answered