IllegalAccessException on protected class member while parsing Excel 2007 file using Apache POI library on AppEngine - google-app-engine

I am trying to parse excel 2007 (.xlsx) file using Apache POI library on Google AppEngine but while doing that I am getting an exception (see below).
java.lang.IllegalAccessException: Class com.google.appengine.tools.development.agent.runtime.Runtime$21 can not access a member of class org.apache.poi.xssf.usermodel.XSSFSheet with modifiers "protected"
So I checked with Apache POI team, but they claim that its an AppEngine issue. I am not sure what is the right place for AppEngine questions, but I know lot of appengine developers monitor Stackoverflow. So posting this question here.
Bug filed for Apache POI team : https://issues.apache.org/bugzilla/show_bug.cgi?id=55665
This bug has a sample maven project, and instructions to reproduce it.
I am not sure how to attach this zip file here.
If any one knows how to fix this then let me know, or right place to file bug.
The key part of the stacktrace is:
java.lang.IllegalAccessException: Class com.google.appengine.tools.development.agent.runtime.Runtime$21 can not access a member of class org.apache.poi.xssf.usermodel.XSSFSheet with modifiers "protected"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:105)
at com.google.appengine.tools.development.agent.runtime.Runtime$22.run(Runtime.java:488)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkAccess(Runtime.java:485)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkAccess(Runtime.java:479)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:123)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:135)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)

I've run into the same issue. I think this is only an issue with the development server. Admittedly, this doesn't fully answer your question but I guess the situation at least isn't as bas as you'd think. To get around the issue I've been developing my POI code in a standard Java project (using dummy data) and then copying it into the App Engine project.
I've logged the issue with Google: https://code.google.com/p/googleappengine/issues/detail?id=11752
If you're interested, in the process of logging the issue, I created a sample project which is also available on App Engine (which works as it's running in the production environment).
Sample project: https://bitbucket.org/bronze/jakarta-poi-issue
App running on production environment: http://bronze-gae-poi-issue.appspot.com/

Related

Java.awt.geom.RectangularShape support on GAE

I'm using the Apache POI library for manipulating a PowerPoint file.
It works great on GAE for inspecting the contents of a PPTX file.
However, if I try to change the contents of a PowerPoint file I get the following GAE error:
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.(RectangularShape.java)
at org.apache.poi.xslf.usermodel.XSLFSimpleShape.getAnchor(XSLFSimpleShape.java:176)
Has anyone had any experience getting around this issue or similar java.awt issues on GAE?
I'm considering hacking the Apache POI source but would rather some kind of native support of java.awt in GAE. I've done some research and:
1) A lot of issues have been raised on GAE for java.awt support and it has been accepted as an issue. Was wondering if this had progressed internally? It was accepted August 2011.
2) There is a project: http://code.google.com/p/appengine-awt/ that is a pure java implementation of java.awt. Does this support java.awt.geom.RectangularShape I wonder?
So I've managed to workaround this for other interested Apache POI users using GAE.
You can do some manipulations on a pre-defined PowerPoint template just avoid any of the methods that require using the underlying java.awt libraries (which are restricted on GAE). My issue was using the createSlide() and importContent() methods. I only need to modify the text so operating on the in-memory version of the PPT file using:
XSLFShape[] shapes = slide.getShapes();
for (XSLFShape shape : shapes) {
if (shape instanceof XSLFTextShape) {
XSLFTextShape textShape = (XSLFTextShape)shape;
switch (shape.getShapeId())
case 1:
textShape.setText("1st text box");
Solves my problem.
Plea to Google - Please provide an API for doing direct manipulations of Google Docs/Presentations. Currently the only solution is to download Google presentation to GAE (in-memory), use Apache POI for the manipulation, and upload as a different Google presentation.

gwt sample project rpc call failure

When i try to run gwt sample project it gives "RPC call failure.An error occurred while attempting to contact the server. Please check your network connection and try again". It was running good before but after i update programs and libraries it gives that error. Which update causes this error or there is other things?
Appengine version:1.7.0
GWT version:2.4.0
Eclipse version:4.2(juno)
JDK version:1.7.0_05
This may not be the problem you are facing but it seems to be the most frequent problem.
Let me predict - you last tried GWT four years ago and you hoarded the sample project hoping to pull it out one day.
And yesterday, you did pull it out. It kinda worked and then you decided to upgrade to the latest 2.4.0. (Actually the latest is 2.5.0-rc1).
Ooops. The web-inf/lib of your project is still faithfully using pre-version 2.2 gwt-servlet jar.
Nope, you can't do that. GWT-RPC data transfer format is version-unstable. Not guaranteed to be compatible from one version to the next.
Simple solution - recreate a new GWT project using the new Google plugin.
Then copy the src and web.xml of your project into the new project.
Or replace the gwt-servlet.jar with the latest. And if you usegwt-servlet-deps.jar, you would need to upgrade that too (but I doubt so, because if you did use gwt-servlet.deps.jar you wouldn't be asking this question).
But why would you keep the gwt sample from an old project?
The samples have remained quite the same over the years. Why not use the samples from the new GWT 2.4.0 download. You don't have to keep the samples. You should try to construct the projects for the samples afresh.
The GWT directory is found under Eclipse's plugins directory, under a long name. Like
plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201205091048-rel-r37/gwt-2.4.0.
In which you will find the samples directory.

is there a way to download my application code from GAE

I accidently deleted my application code from my own machine, however it's running on Google App Engine (GAE), is there a way I could download it from there?
--
app engine actually recently added the ability for the developer who uploaded a given app version to download its source code:
http://code.google.com/appengine/docs/python/tools/uploadinganapp.html#Downloading_Source_Code
You cannot do this unless you have prepared your app ahead of time properly. There is a chance the trick described by Nick in the duplicate question here might work for you. Otherwise, I would suggest using source control like git or svn.

Google App Engine access to code

Is it possible to access or download my code that is running on Google App Engine? For instance, say my hard drive crashes and I have not saved my code on any kind of external repository. Is there any way to recover?
No, it is not possible. You compile your code on your machine and ship up the compiled code.
If you have a source repository, always make sure that you have a backup.
GAE does not have a mechanism for you to download your binaries, so reverse engineering them is not possible except from your own copies.
Of course you could always host your project on GitHub or SourceForge
see also:
how to download google appengine (uploaded)application files
Can I restore my source code that has been uploaded into Google AppEngine?
How do I download the source code of a google app engine project?
Download source code of deployed GAE application
Get source of appengine published version
I can't find it now, but I remember reading a post where they were pretty specific about NOT being able to do that. The gist of it was that they were not a backup service and that you were responsible for backing up your own code.
There is a "datastore backup and restore" feature on the project roadmap though: http://code.google.com/appengine/docs/roadmap.html I've skimmed over a few posts where people talk about ways to backup the database now without that the official sanctioned feature implemented... of course your datastore isn't your code.

Is it possible to deploy ColdFusion code on Google App Engine for Java?

Since ColdFusion is itself Java-based, I would imagine it's not too much of a stretch to suggest that CFML code could be deployed on Google App Engine.
BlueDragon is a commercial solution for deploying CFML code on Java servers.
It's described in this thread how someone got OpenBD (Blue Dragon) running on App Engine:
OpenBD on Google App Engine for Java
Are there any open source alternatives
that could be used for App Engine?
Railo is another obvious candidate here, and some people appear to be trying to tweak it for use on Google App Engine.
I am putting together some demos that run on Open BlueDragon, which in turn is running on Google App Engine. The list is small at the moment, but eventually it should give you a good idea of what is opssible with OpenBD and GAE.
http://www.brighthub.com/hubfolio/matthew-casperson/blog/archive/2010/05/12/cold-fusion-demos.aspx
Check out
http://www.stax.net/ - Stax networks made by a former Allaire(r)?
Works great, supports coldfusion out of the ..cloud. You download a precompiled source file, put your stuff in, upload it and it all works, no fighting with it.
I know google app engine is quite restrictive, it will involve opening up the source and removing everything that attempts to write to the file system, and changing your database interaction.
You can checkout this thread and group as a resource for Open BlueDragon as well as the wiki. Looks like they have a branch already which is working towards GAE compatibility.
On the Railo side of the CFML open source pond you can reference this article from help compiling Railo on your own from the source.
Joining both of their respective google groups and asking questions should yield fruitful as well.
Good Luck!

Resources