FileNotFoundException (Access is denied)

Hello,
I’ve been trying to fix my problem for few months now, any tips or ideas would be appreciated.
thank you in advance.

I’m using Java 7; tomcat-7.0.34; aspose.pdf-16.12.0
I’m getting the follow error sometimes. not all the time. sometimes it works fine.

Message:
File not found File: \bhc.cnb\Apps\A-C\Biomdata\Wr_CDPT\temp\dave\16244_dave_export_final_20170530210205.pdf

StackTrace:
com.aspose.pdf.internal.ms.System.IO.FileNotFoundException: File not found File: \bhc.cnb\Apps\A-C\Biomdata\Wr_CDPT\temp\dave\16244_dave_export_final_20170530210205.pdf
File name: ‘\bhc.cnb\Apps\A-C\Biomdata\Wr_CDPT\temp\dave\16244_dave_export_final_20170530210205.pdf’ —> \bhc.cnb\Apps\A-C\Biomdata\Wr_CDPT\temp\dave\16244_dave_export_final_20170530210205.pdf (Access is denied)
com.aspose.pdf.internal.p810.z3.(Unknown Source)
com.aspose.pdf.internal.p810.z3.(Unknown Source)
com.aspose.pdf.internal.p810.z3.(Unknown Source)
com.aspose.pdf.internal.p652.z28.(Unknown Source)
com.aspose.pdf.internal.p652.z28.(Unknown Source)
com.aspose.pdf.internal.p652.z28.(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)
com.aspose.pdf.facades.SaveableFacade.save(Unknown Source)
com.bayer.dave.PdfExport.closeBookmarks(PdfExport.java:78)
com.bayer.dave.PdfExport.createPdf(PdfExport.java:654)
=================================================================
in my code, I’m creating the content (and create table and return table), save and then addbookmark then save. my inFile and OutFile path/name are the same. but I saw from your forum that this shouldn’t be problem. The weird thing is sometimes it works fine and sometimes i get the error.
=============================================================
createContent(outFile, tableOne, tableTwo, tableOneTitle, tableTwoTitle, docTitle, docExp, type);
Document doc = new Document();

createTable(rowTitles, columnNames, columnWidths, _tableOne);

doc.save(anOutFile);

addBookmark(outFile, outFile, tableOneBook, 1, tableTwoBook, tableTwo_StartPage);

Document pdfDocument = new Document(inFile);

pdfDocument.save(outFile);

Hi,


Thank you for contacting support. You may be opening a single file multiple times in the code and not disposing old objects. Please go through this StackOverFlow thread: Access is Denied Java IO file not found exception. However, if this does not help, then please send complete details of the use case, including source files, complete code and environment details. We will investigate and share our findings with you.

Thank you so much for the quick reply.

the problem occurs once in a while… there’s no consistency.

I attached my source code. I’ve tried to close the opened objects but still had the similar error.

file close lines are commented out because I saw someone commented that save should close the file. Still didn’t help.

createPdf() is the Main.

I’m using Eclipse as IDE.

JDK1.7

apache-tomcat-7.0.34



Hopefully I’m not making things too confusing. thank you so much!

Hi,


Thank you for the inquiry. You are fetching data from the Database, and code is also not in fully compilable form. Please simplify the use case as much as possible and share all assemblies which you have referenced. Kindly also use input data in the form of lists and remove the dependency of the Database. Once all the above resources are available to us, then we will be able to further investigate the problem in our environment.