You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/03/17 21:04:22 UTC

[Bug 59194] New: org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

            Bug ID: 59194
           Summary: org.apache.poi.ss.util.CellRangeAddressBase.getRectang
                    le() throws NoClassDefFoundError on Google App Engine
           Product: POI
           Version: 3.14-FINAL
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: SS Common
          Assignee: dev@poi.apache.org
          Reporter: rahul.herwadkar@gmail.com

The following code example works fine with poi-3.13-20150929.jar on Google App
Engine environment:

      Workbook oWorkbook = new HSSFWorkbook();
      Sheet oSheet = oWorkbook.createSheet("Analysis");
      ...
      <code to init sRowIndex, oItemList etc.>
      ...
      oSheet.addMergedRegion(new CellRangeAddress(sRowIndex, sRowIndex, 3,
          oItemList.size() + 2));

The same code throws java.lang.NoClassDefFoundError error with latest
poi-3.14-20160307.jar:

      java.lang.NoClassDefFoundError: java.awt.geom.RectangularShape is a
restricted class. Please see the Google App Engine developer's guide for more
details.
    at
com.google.apphosting.runtime.security.shared.stub.java.awt.geom.RectangularShape.<clinit>(RectangularShape.java)
    at
org.apache.poi.ss.util.CellRangeAddressBase.getRectangle(CellRangeAddressBase.java:164)
    at
org.apache.poi.ss.util.CellRangeAddressBase.intersects(CellRangeAddressBase.java:140)
    at
org.apache.poi.hssf.usermodel.HSSFSheet.validateMergedRegions(HSSFSheet.java:722)
    at
org.apache.poi.hssf.usermodel.HSSFSheet.addMergedRegion(HSSFSheet.java:684)
        ...
        <application code similar to example code snippet goes here>

This is a regression between poi-3.13-20150929.jar and 3.14-20160307.jar.

The implementation for getRectangle() method in CellRangeAddressBase.java has a
TODO comment indicating a temporary workaround in rel 3.14:

    // TODO: Replace with an intersection code that doesn't rely on java.awt
    // Don't let this temporary implementation detail leak outside of this
class
    private final Rectangle getRectangle() {
        int firstRow, firstCol, lastRow, lastCol;

        if (!isFullColumnRange()) {
            firstRow = Math.min(_firstRow, _lastRow);
            lastRow = Math.max(_firstRow,  _lastRow);
        }
        else {
            firstRow = 0;
            lastRow = Integer.MAX_VALUE;
        }
        if (!isFullRowRange()) {
            firstCol = Math.min(_firstCol, _lastCol);
            lastCol = Math.max(_firstCol, _lastCol);
        }
        else {
            firstCol = 0;
            lastCol = Integer.MAX_VALUE;
        }
        return new Rectangle(firstRow, firstCol, lastRow-firstRow+1,
lastCol-firstCol+1);
    }

My use case is to create an MS Excel spreadsheet. As mentioned before, this use
case is working in rel 3.13 but breaks in 3.14 in the Google App Engine
environment.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #10 from Javen O'Neal <on...@apache.org> ---
Refer to bug 56835
Unit test which demonstrates that adding a comment in the same cell twice is
not allowed (since it would produce a corrupt workbook):
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java?r1=1633397&r2=1633396&pathrev=1633397

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #9 from Javen O'Neal <on...@apache.org> ---
https://poi.apache.org/changes.html
> fix 58443 - Prohibit adding merged regions that would overlap with existing merged regions

In POI 3.14, addMergedRegion was modified to check for overlapping merged
regions. The merged region validation calls java.awt.Rectangle.intersects,
regardless of whether there are overlapping merged regions or not.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #2 from Javen O'Neal <on...@apache.org> ---
In r1711586 from bug 58443, I added java.awt.Rectangle.intersects to check if
two merged cell regions intersect. [1]

I could have duplicated the logic used by java.awt.Rectangle.intersects in POI,
but (falsely) assumed that all applications using POI would have access to
java.awt.Rectangle. Apparently this isn't the case for Google App Engine, which
off-limits this class. I'd like to avoid duplicating the intersects logic into
POI in fear of an incorrect implementation.

Could you also investigate if your Google App Engine setup is to blame? Others
solved this problem by removing older Jetty jars [2,3,4]

[1]
https://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java?r1=1711586&r2=1711585&pathrev=1711586

[2] https://code.google.com/p/googleappengine/issues/detail?id=2324#c3
[3]
http://stackoverflow.com/questions/15673942/urlstreamhandler-is-a-restricted-class
[4]
http://stackoverflow.com/questions/11672559/java-awt-geom-rectangularshape-support-on-gae

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #11 from Javen O'Neal <on...@apache.org> ---
> regardless of whether there are overlapping merged regions [in the workbook] or not

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #4 from Javen O'Neal <on...@apache.org> ---
This isn't the first time that GAE has had problems with POI [1]. A similar
error occurred in POI 3.6. Unfortunately, the Google Code URL in the answer no
longer works, so here's an archive [2].

> Apache POI
> Version(s)	?
> Status	INCOMPATIBLE
> Apache POI relies on several classes not in the JRE class whitelist including java.awt.Color. A bug has been filed at https://issues.apache.org/bugzilla/show_bug.cgi?id=47497.

I imagine you would have got the same restricted class error in POI 3.13 had
your code tried to use a class that relied on a method or object from java.awt.

In order to get GAE compatibility, we'd need to replace nearly every usage of
java.awt in POI [3]. It might also be worth trying to get (portions of)
java.awt.* whitelisted on Google App Engine. Did Google exclude java.awt
because it poses a security risk?

[1] https://groups.google.com/forum/#!topic/google-appengine-java/ARDWKSLtXz0
[2]
https://web.archive.org/web/20120115214324/http://code.google.com/p/googleappengine/wiki/WillItPlayInJava
[3]
https://web.archive.org/web/20120119065142/http://code.google.com/appengine/docs/java/jrewhitelist.html

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #8 from rahul.herwadkar@gmail.com ---
So the merged cells in my spreadsheet happen to overlap? That's interesting...
Thanks for the quick followup. I'll check and fix my code logic as well.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #15 from Javen O'Neal <on...@apache.org> ---
CellRangeAddressBase#intersect implementation replaced with a
java.awt.Rectangle-free implementation in r1749226 as part of bug 56958.

You should now be able to use the validating version of addMergedRegion on
Google App Engines for POI 3.15 beta 2 and beyond.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

rahul.herwadkar@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #3 from rahul.herwadkar@gmail.com ---
There are no Jetty jars in my GAE setup. Outside of the default GAE jars, this
is what I package into my app:

commons-codec-1.10.jar
commons-lang3-3.4.jar
commons-logging-1.2.jar
commons-math3-3.6.jar
gson-2.6.2.jar

Currently, the only workaround I trust is to revert to poi v3.13. What are my
other options? Do you know of a GAE friendly/certified replacement for
java.awt?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #7 from Javen O'Neal <on...@apache.org> ---
(In reply to rahul.herwadkar from comment #6)
> 1) Merge cells for the table column headers.

This is why you're getting the error. I discovered that I could create a
corrupt workbook by adding a merged region B2:C3 when a workbook already
contained a merged region A1:B2, since the two merged regions intersect.

If you want to skip this intersection check, use
XSSFSheet.addMergedRegionUnsafe. I will add HSSFSheet.addMergedRegionUnsafe in
a nightly build, which should get you around this problem.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #12 from Javen O'Neal <on...@apache.org> ---
Disregard comment 10

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #13 from Javen O'Neal <on...@apache.org> ---
(In reply to Javen O'Neal from comment #7)
> If you want to skip this intersection check, use
> XSSFSheet.addMergedRegionUnsafe. I will add HSSFSheet.addMergedRegionUnsafe
> in a nightly build, which should get you around this problem.

Implemented this workaround in r1736155 (bug 59212). Use any nightly or POI
3.15 beta 1 (when it's released) to avoid this java.awt dependency.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #5 from rahul.herwadkar@gmail.com ---
Created attachment 33683
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33683&action=edit
Excel file generated from POI APIs

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #14 from Dominik Stadler <do...@gmx.at> ---
I think the regression from 3.13 should work now if using the new
unsafe-method. I don't think we plan to get rid of all of java.awt as it is
used in a number of  places, especially Powerpoint support. Specific things
that fail on GAE can be reported as separate bugs so we can decide on a
case-by-case basis.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

--- Comment #6 from rahul.herwadkar@gmail.com ---
The above attachment is an example of the excel file generated from my app.

I don't do anything out of the ordinary with the POI APIs. The only special
things I do are:

1) Merge cells for the table column headers.

2) Link a cell to another cell in same or different sheet.

I have no idea why GAE would restrict usage of java.awt. I tried to google the
error but did not come across any meaningful result.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59194] org.apache.poi.ss.util.CellRangeAddressBase.getRectangle() throws NoClassDefFoundError on Google App Engine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59194

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
Any chance you could work up a GAE-friendly replacement for the logic?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org