troubleshooting Question

FileNotFoundException:. ...(Permission denied)

Avatar of royjayd
royjayd asked on
Java
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
			out.flush();
			out.close();

		} 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/custom.sh

custom.sh contains
java -Dproj.env=dev -jar $ROOT/CustomExport.jar   (this is the jar which contains the above java code)

so when i run custom.sh 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  {} java.io.FileNotFoundException: custom_03_26_2013.xls (Permission denied)

 1va.io.FileNotFoundException: 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
thanks.
ASKER CERTIFIED SOLUTION
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