troubleshooting Question

FileNotFoundException:. ...(Permission denied)

Avatar of royjayd
royjayd asked on
14 Comments3 Solutions4750 ViewsLast Modified:
hi guys

In my application i have this problem which i am struggling for past 2 days

My java process is trying to write a file to the directory in unix box using FileOutputStream
The code goes like this

public class CustomExport{
	public void saveReport() {
		try {
			SimpleDateFormat dateFormatter = new SimpleDateFormat("MM_dd_yyyy");
			String date = dateFormatter.format(new Date());
			FileOutputStream out = new FileOutputStream(new File("custom" + date + ".xls"));
			hSSFWorkbook.write(out);  //org.apache.poi.hssf.usermodel.HSSFWorkbook  api is used to generate excel

		} catch (IOException e) {
			LOG.error(" Error occured  {} " + e);
			LOG.error(" Error Message  {} " + e.getMessage());

The above java process runs from this folder in unix box :  /custom/export/excel/ contains
java -Dproj.env=dev -jar $ROOT/CustomExport.jar   (this is the jar which contains the above java code)

so when i run it inovkes the saveReport() and it goes to the catch block and prints the following errors

12337 [main] ERROR com.crisp.excel.CustomExport  -  Error occured  {} custom_03_26_2013.xls (Permission denied) custom_03_26_2013.xls (Permission denied)
2337 [main] ERROR com.crisp.excel.CustomExport  -  Error Message  {} custom_03_26_2013.xls (Permission denied)

I understand i am missing permissions but where am i missing the permissions ?
Is this write permission of the file custom_03_26_2013.xls  which is generated on the fly  or the permission of /custom/export/excel folder where it is supposed to write?

Any help would be greatly apprecaited
Join our community to see this answer!
Unlock 3 Answers and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros