views:

170

answers:

1

I try to create a new file inside a JSP and try to save it:

final File file1 = new File("piechart.png");
ChartUtilities.saveChartAsPNG(file1, targetChart, 600, 400, info);

I get a AccessControlException:

java.security.AccessControlException: access denied (java.io.FilePermission piechart.png write)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
    at java.security.AccessController.checkPermission(AccessController.java:546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:122)
    at java.lang.SecurityManager.checkWrite(SecurityManager.java:962)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
         at org.jfree.chart.ChartUtilities.saveChartAsPNG(ChartUtilities.java:328)

The eventual goal is to create and display the file in the same JSP:

<IMG SRC="piechart.png" WIDTH="600" HEIGHT="400"   BORDER="0" USEMAP="#chart">

Also, this is inside the google app engine environment.

+1  A: 

Google app engine doesn't support writing to disk.

From the FAQ:

Writing to local files is not supported in App Engine due to the distributed nature of your application. Instead, data which must be persisted should be stored in the distributed datastore. For more information see the documentation on the runtime sandbox.

seth