0

I have created a REST API that is getting called asynchronously (.asyncApply), and that API is trying to write a file but getting permission denied as I have changed all types of permissions are in place in the respective directory.

I have researched a lot but not getting anything solution on this

Is there a possibility that an asynchronous call is creating the issue?

PS: this issue is occurring intermittently. Also, I am using Play-frame work and WSCliet to hit REST API.

UPDATE - api flow is like this :

Request :

Document xml = play.libs.XML.fromString("<document></document>");
 ws.url(url).post(xml);

Processing Response :

completionStage<Document> documentPromise =
ws.url(url).get().thenApplyAsync(r -> r.getBody(xml()));

during processing, it hits some API Asynchronously and while writing file it gets an exception like

2021-05-17 12:08:03.079 +0530 [DEBUG] from com.zaxxer.hikari.pool.PoolBase:? in
                application-akka.actor.default-dispatcher-1233 - HikariPool-2 - Reset (autoCommit) on connection oracle.jdbc.driver.T4CConnection@1a8c2ee6
2021-05-17 12:08:03.145 +0530 [INFO] from utils.BulkOutputFileCreator:? in
                application-akka.actor.default-dispatcher-1233 - Exception occurred in writing file
java.io.FileNotFoundException: NF/BRO_PP/SMAPLE/outPut1234.csv (Permission denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
    at java.io.PrintWriter.<init>(PrintWriter.java:184)
    
suv1sh
  • 43
  • 1
  • 10
  • This is a surely a matter for your operating system, not Java. – iggy May 17 '21 at 16:24
  • Have you tried changing the path and testing it with another very simple path. A lot of file problems arise when the path is not correct. – Renis1235 May 18 '21 at 06:50
  • this issue is occurring intermittently, as I have mentioned, other flies are getting successfully written by same method – suv1sh May 18 '21 at 15:43
  • @iggy, I didn't get you would you be elaborative a bit? – suv1sh May 18 '21 at 16:04
  • @Renis1235, this code is running fine in lower environments but it got stuck in the higher environment so not able to debug it also, but this issue is not reproducible in lower environment that is the main issue I am seeking help from you guys – suv1sh May 18 '21 at 16:06
  • https://www.playframework.com/documentation/2.8.x/JavaWS – suv1sh May 18 '21 at 16:07

1 Answers1

0

https://www.suse.com/support/kb/doc/?id=000019272

This web page finally gave me hope that my code is not having any issue so we debugged in the Linux side where our code was deployed.

we found a very strange behavior from NFS side, our directory permission was kept fluctuating from 777 to 755 between NFS mount point to our server-side directory

so we gave 777 from NFS server directly and the above-mentioned functionality was working fine.

So basically issue was occurring due to permission which was fluctuating.

suv1sh
  • 43
  • 1
  • 10