Bug 53974 - Can't create xls files in google app engine
Summary: Can't create xls files in google app engine
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.8-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-10-05 16:47 UTC by fabien.sartor
Modified: 2012-10-10 11:10 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description fabien.sartor 2012-10-05 16:47:37 UTC
The Apache POI 3.8 can't create xls files with google app engine.

Indeed, at the line 1098 of InternalWorkbook.java , POI uses System.getProperty("user.name").
Usage of System.xxx is forbiden with app engine.

There is a usage of catch (AccessControlException e) { .. }.
You can add a new catch of NullPointerException like this :

--- InternalWorkbook.java.orig  2012-03-17 14:18:59.000000000 +0100
+++ InternalWorkbook.java.new   2012-10-05 18:17:25.000000000 +0200
@@ -1100,6 +1100,8 @@
                 // AccessControlException can occur in a restricted context
                 // (client applet/jws application or restricted security server)
+        } catch (NullPointerException e) {
+            retval.setUsername("POI");
         return retval;

I try this fix and it works well.

Or you can modify the setUsername function in WriteAccessRecord.java (line 99).

PS: I don't use java.awt.x fonctionnalities.

My stack trace is : 

	at org.apache.poi.hssf.record.WriteAccessRecord.setUsername(WriteAccessRecord.java:101)
	at org.apache.poi.hssf.model.InternalWorkbook.createWriteAccess(InternalWorkbook.java:1098)
	at org.apache.poi.hssf.model.InternalWorkbook.createWorkbook(InternalWorkbook.java:367)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
	at fsart.diffTools.outputDriver.Impl.CsvExcelView2SpecialAppEngine.<init>(CsvExcelView2SpecialAppEngine.scala:75)
	at fsart.diffTools.webApp.CompareFiles.doGet(CompareFiles.scala:68)
Comment 1 Yegor Kozlov 2012-10-10 11:10:35 UTC
Fixed in r1396543