GoogleFileService doesn't work on appengine-java-sdk-1.2.5

9 views
Skip to first unread message

tytung

unread,
Sep 10, 2009, 7:32:27 AM9/10/09
to GoogleFileService
Hello everyone,

I think the following problem will have effects on all my
GoogleFileService versions.

I updated my appengine-java-sdk to version 1.2.5, and I found the
exception in "file_list.jsp".

--------------------------------------------------------------------------------------------
java.lang.NullPointerException
at
sinica.googlefileservice.server.servlet.FileDownloadServlet.doGet
(FileDownloadServlet.java:62)

List<GoogleUnit> googleUnits = g.getGoogleUnits();
for (GoogleUnit gUnit : googleUnits) {
o.write(gUnit.getData().getBytes()); // line 62
o.flush();
}
--------------------------------------------------------------------------------------------

Well, I 'm so busy and have no time to fix this problem now.
Maybe you can still use appengine-java-sdk-1.2.1 which I used for
development before.

tytung

Alyxandor

unread,
Oct 10, 2009, 5:37:49 AM10/10/09
to GoogleFileService
Although the current implementation is in shambles, you can check out
my GAE + GWT project, http://code.google.com/p/xbook . I based my
file abstraction layer on Google File Service, and will properly cite
all modified / source based on ty tung's work when it's in an alpha
state and released in a jar w/ proper documentation. You have to
check out the source, and then set up two projects, one is the xCore
project, which contains all the gwt source, and the second is the main
trunk, that has all the appengine code, with spatterings of gwt for
taste. The current host page needed is X.jsp, and there's a method in
src/ai/yx/common/client/COMMON.java called xServer() that you will
need to set to your server's proper address. There's lot of other
changes needed that I haven't uploaded either, so you may just want to
look at the ai/yx/file/client folder and rip out the classes and
queries I use.

When this code is "good enough" by my standards, I will release it
properly, but until then, you can feel free to hack on what I hacked
from Ty Tung's implementation. Please note that I use GWT, so all
objects must be detached before sending them to the client over RPC.
I also find that the appengine server doesn't like performing queries
with multiple non-detached objects in scope, so I close and reopen the
PersistenceManager between each nuclear transaction. Because I do
this, I almost always call pm.detachCopy(), which ensures that all
fields are filled from the DB {as, I do believe, it performs lazy
loading so that some fields won't be filled unless they are directly
accessed within your server side code, but I could easily be wrong on
this}.

Many thanks to Ty Tung for writing Google File Service; I wouldn't
have built the xFile Service without it!
Message has been deleted

tytung

unread,
Oct 27, 2009, 12:23:25 AM10/27/09
to GoogleFileService
You're welcome.
Keep up the good work. :)

Zhang Yu

unread,
Nov 5, 2009, 10:27:57 AM11/5/09
to GoogleFileService
Hi tytung,

I encountered the same problem, and after several hours struggle I
found out the solution was so easy.

Just need to add three lines in function "getGoogleFileById" as
another trick. And then downloading start to working again.

See following:
public static GoogleFile getGoogleFileById(String fileId) {
GoogleFile g = null;
if (DatastoreUtils.isKey(fileId)) {
// get data from Google datastore
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
g = pm.getObjectById(GoogleFile.class, fileId);

//Adding another trick for Blod
for (GoogleUnit gu: g.getGoogleUnits())
{
gu.getData();//the trick.
}

g.setGoogleUnits(g.getGoogleUnits()); //trick

} catch (JDOObjectNotFoundException e) {
//no entities in Google datastore
} finally {
pm.close();
}
}
return g;
}

Anyway, thank you for your good work which is just what I need now:)

Zhang Yu

Zhang Yu

unread,
Nov 5, 2009, 10:32:12 AM11/5/09
to GoogleFileService
Hi,

It looks that the App Engine now supports lazy loading for child
elements.

I'm not sure. If true, this is a good thing...

tytung

unread,
Nov 5, 2009, 1:02:13 PM11/5/09
to GoogleFileService
Good job, Zhang Yu.
Thank you very much.
> > tytung- 隱藏被引用文字 -
>
> - 顯示被引用文字 -
Reply all
Reply to author
Forward
0 new messages