Re: [scala] Google App Engine for Scala!

256 views
Skip to first unread message

Atsuhiko Yamanaka

unread,
Apr 11, 2009, 3:53:32 AM4/11/09
to David Pollak, Scala list, lif...@googlegroups.com
Hi,

On Fri, Apr 10, 2009 at 10:03 PM, David Pollak
<feeder.of...@gmail.com> wrote:
> Thank you! Thank you! Thank you!
> I'd like to kiss you (but my wife might get upset)
> Next time you come to the Bay Area, I will buy you lunch or dinner!

If I get an opportunity to be there in the future, I'll want to enjoy
lunch with you!

> On Apr 10, 2009 1:46 AM, "Atsuhiko Yamanaka" <atsuhiko...@gmail.com> wrote:
> As a proof of concept, I have succeeded to run lift-example on GAE/J, it is running at
>  http://lift-example.appspot.com/index
>
> Of course, CometAcotr is not functional, and DB is not available
> because of jdbc usage.
> In this weekend, if possible, I will try JPA.
>
> Here is a fork of liftweb source code to run lift-example on GAE/J,
>  http://github.com/ymnk/liftweb/tree/master

It seems that JDBC API must not have be forbidden on GAE/J .
I have succeeded to use H2 mem db by updating to its latest version[1] and
now DB functionalities have worked on
http://lift-example.appspot.com/index

However, it is not adequate for the practical usages, of course.
FYI, I found an interesting message[2] about a plan to implement
"JDBC to com.google.appengine.api.datastore wrapper"

PS. I will add CC to lif...@googlegroups.com and further discussions
should be there.

[1] http://www.h2database.com/html/changelog.html
[2] http://groups.google.com/group/google-appengine-java/msg/71278bbee901c652


Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
+1-415-578-3454
Fax +81-22-224-8773
Skype callto://jcraft/

David Pollak

unread,
Apr 11, 2009, 9:43:46 AM4/11/09
to lif...@googlegroups.com
On Sat, Apr 11, 2009 at 12:53 AM, Atsuhiko Yamanaka <atsuhiko...@gmail.com> wrote:
Hi,

On Fri, Apr 10, 2009 at 10:03 PM, David Pollak
> Thank you! Thank you! Thank you!
> I'd like to kiss you (but my wife might get upset)
> Next time you come to the Bay Area, I will buy you lunch or dinner!

If I get an opportunity to be there in the future, I'll want to enjoy
lunch with you!

Cool.
 

>
> Here is a fork of liftweb source code to run lift-example on GAE/J,
>  http://github.com/ymnk/liftweb/tree/master

It seems that JDBC API must not have be forbidden on GAE/J .
I have succeeded to use H2 mem db by updating to its latest version[1] and
now DB functionalities have worked on
However, it is not adequate for the practical usages, of course.
FYI, I found an interesting message[2] about a plan to implement
"JDBC to com.google.appengine.api.datastore wrapper"

GAE supports JPA and there's a lot of Lift JPA support... so maybe we can update the example code to use JPA and we'll have persistence via BigTable.

In terms of Comet support (which relies on Actor support), I've got some ideas on how to make the Actors always use the current thread which will mean no spawning threads.  We'll also have to set the default Comet timeout to 25 seconds as to not violate the GAE 30 second max request rule.

Fun stuff to do next week.

Thanks!

David
 


PS. I will add CC to lif...@googlegroups.com and further discussions
should be there.

[1] http://www.h2database.com/html/changelog.html
[2] http://groups.google.com/group/google-appengine-java/msg/71278bbee901c652


Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
  +1-415-578-3454
Fax +81-22-224-8773
Skype callto://jcraft/



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

Atsuhiko Yamanaka

unread,
Apr 11, 2009, 11:46:52 AM4/11/09
to lif...@googlegroups.com
Hi,

On Sat, Apr 11, 2009 at 10:43 PM, David Pollak
<feeder.of...@gmail.com> wrote:
> GAE supports JPA and there's a lot of Lift JPA support... so maybe we can
> update the example code to use JPA and we'll have persistence via BigTable.

I may have missed something, but it seems that the combination of scala and
DataNucleus(used via JPA on GAE/J) does not work, as far as I have been trying.
Are there somebody who have succeeded to use scala and JPA on GAE/J?
Can we work around this problem by implementing entity classes in Java?

João Pereira

unread,
Apr 11, 2009, 12:06:16 PM4/11/09
to lif...@googlegroups.com
Hi,

I'm trying to have a simple lift app running on GAE.
The app is generated from the archetype-blank

I can deploy it on GAE, but I'm getting :

Failed LiftFilter

java.lang.NoClassDefFoundError: java.net.InetAddress is a restricted class. Please see the Google App Engine developer's guide for more details.

When running the app on GAE

What do I need to have a simple lift app running on GAE?

A newbie,
--
João Miguel Pereira, PMP
http://jpereira.eu
http://www.linkedin.com/in/joaomiguelpereira
joaomigue...@gmail.com
(351) 96 275 68 58

walterc

unread,
Apr 11, 2009, 12:17:19 PM4/11/09
to Lift
cool, guys, looking forward to it, especially the current thread actor
bit.

On Apr 11, 9:43 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> On Sat, Apr 11, 2009 at 12:53 AM, Atsuhiko Yamanaka <
>
> >http://groups.google.com/group/google-appengine-java/msg/71278bbee901...
>
> > Sincerely,
> > --
> > Atsuhiko Yamanaka
> > JCraft,Inc.
> > 1-14-20 HONCHO AOBA-KU,
> > SENDAI, MIYAGI 980-0014 Japan.
> > Tel +81-22-723-2150
> >   +1-415-578-3454
> > Fax +81-22-224-8773
> > Skype callto://jcraft/
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890

Atsuhiko Yamanaka

unread,
Apr 12, 2009, 10:00:21 AM4/12/09
to lif...@googlegroups.com
Hi there,

On Sun, Apr 12, 2009 at 12:46 AM, Atsuhiko Yamanaka
<atsuhiko...@gmail.com> wrote:
> Hi,
>
> On Sat, Apr 11, 2009 at 10:43 PM, David Pollak
> <feeder.of...@gmail.com> wrote:
>> GAE supports JPA and there's a lot of Lift JPA support... so maybe we can
>> update the example code to use JPA and we'll have persistence via BigTable.
>
> I may have missed something, but it seems that the combination of scala and
> DataNucleus(used via JPA on GAE/J) does not work, as far as I have been trying.
> Are there somebody who have succeeded to use scala and JPA on GAE/J?
> Can we work around this problem by implementing entity classes in Java?

FYI, it must be trivial, but I have confirmed that Lift(org.scala_libs.jpa) has
persistence via BigTable through JPA on GAE/J by using entity classes in Java!

Derek Chen-Becker

unread,
Apr 12, 2009, 5:08:54 PM4/12/09
to lif...@googlegroups.com
Cool, so the ScalaJPA stuff works fine under GAE?

Derek

Atsuhiko Yamanaka

unread,
Apr 14, 2009, 1:55:27 AM4/14/09
to lif...@googlegroups.com
Hi,

On Sat, Apr 11, 2009 at 10:43 PM, David Pollak
<feeder.of...@gmail.com> wrote:
> GAE supports JPA and there's a lot of Lift JPA support... so maybe we can
> update the example code to use JPA and we'll have persistence via BigTable.

I have integrated to JPADemo to lift_example, and everybody can try it at
http://lift-example.appspot.com/jpademo/
http://lift-example.appspot.com/jpademo/authors/list
http://lift-example.appspot.com/jpademo/books/list

The data has been really stored in BigTable!
As I wrote, it has been done by JPA with entity classes written in Java.

Atsuhiko Yamanaka

unread,
Apr 14, 2009, 2:16:00 AM4/14/09
to lif...@googlegroups.com
Hi,

On Mon, Apr 13, 2009 at 6:08 AM, Derek Chen-Becker
<dchen...@gmail.com> wrote:
> Cool, so the ScalaJPA stuff works fine under GAE?

I have some problems.
For example, in some cases, ScalaEtityManager#find could not find the object.

I mean that it could not find an object,
Model.find[Author](classOf[Author], id) ,
but I got it by the following,
Mode.createNamedQuery[Author]("findAllAuthors").getResultList().filter(_.getId
== id)(0)

I, however, have guessed that problem has not come from ScalaJPA.
It may be from DataNucleus or its driver for GEA's datastore.
I have encountered several weired behaviors in using that datastore.

Derek Chen-Becker

unread,
Apr 14, 2009, 10:35:08 AM4/14/09
to lif...@googlegroups.com
Hmmm. I wonder if the following would work:

Model.createQuery[Author]("from Author a where a.id = :id").setParameter("id", id).findOne

If that works it would be more efficient since you would be doing the filter on id in the query instead of after pulling the whole table :)

Derek

Atsuhiko Yamanaka

unread,
Apr 14, 2009, 11:14:06 AM4/14/09
to lif...@googlegroups.com
Hi,

On Tue, Apr 14, 2009 at 11:35 PM, Derek Chen-Becker
<dchen...@gmail.com> wrote:
> Hmmm. I wonder if the following would work:
>
> Model.createQuery[Author]("from Author a where a.id = :id").setParameter("id", id).findOne
>
> If that works it would be more efficient since you would be doing the filter
> on id in the query instead of after pulling the whole table :)

Yes, "select from net.liftweb.example.model.Authora where a.id = :id"
works well;
I mean that, without "select",
" java.lang.IllegalArgumentException: JPQL Query should always start
with SELECT/UPDATE/DELETE"
will be thrown, and in current GAE/J system the class name must be
fully qualified.

And also, I don't know the reason, but Model.find works fine now ;-(

Derek Chen-Becker

unread,
Apr 14, 2009, 1:13:11 PM4/14/09
to lif...@googlegroups.com
Doh. There are my Hibernate roots showing through. HQL doesn't require the select (it's implicit if you only have one class to select from). I don't like inconsistent behavior, so that's a little strang about find working again.

Derek

刘浩

unread,
Apr 20, 2009, 9:16:41 AM4/20/09
to lif...@googlegroups.com
Hi,

Could anyone share the impelmentation of your JPA demo in GAE?
Actually I encounter some problem during deploy them in GAE.

a. The keys, GAE do not like Long as Key in OneToMany relation, So I use the Key type provided by GAE
b. Model.mergeAndFlush(author) did not work as I expected. It could not update, and only do insert. So I changed the code
    if (author.id == null) {
       Model.persistAndFlush(author)
    } else {
       val tmp = Model.find(classOf[Author], author.id)
       tmp.get.name = author.name
       Model.mergeAndFlush(tmp.get)
    }
    I think it is some attach/detach problem.

Thanks

2009/4/15 Derek Chen-Becker <dchen...@gmail.com>

Atsuhiko Yamanaka

unread,
Apr 20, 2009, 9:57:51 AM4/20/09
to lif...@googlegroups.com
Hi,

On Mon, Apr 20, 2009 at 10:16 PM, 刘浩 <sniper...@gmail.com> wrote:
> Hi,
>
> Could anyone share the impelmentation of your JPA demo in GAE?
> Actually I encounter some problem during deploy them in GAE.
>
> a. The keys, GAE do not like Long as Key in OneToMany relation, So I use the
> Key type provided by GAE
> b. Model.mergeAndFlush(author) did not work as I expected. It could not
> update, and only do insert. So I changed the code
> if (author.id == null) {
> Model.persistAndFlush(author)
> } else {
> val tmp = Model.find(classOf[Author], author.id)
> tmp.get.name = author.name
> Model.mergeAndFlush(tmp.get)
> }
> I think it is some attach/detach problem.

Yes, I have also the same phenomenon, and I also have guessed that
there must be such an attache/detach problem.

Atsuhiko Yamanaka

unread,
Apr 20, 2009, 10:16:31 AM4/20/09
to lif...@googlegroups.com
Hi,

On Sun, Apr 12, 2009 at 11:00 PM, Atsuhiko Yamanaka


> FYI, it must be trivial, but I have confirmed that Lift(org.scala_libs.jpa) has
> persistence via BigTable through JPA on GAE/J by using entity classes in Java!

FYI, I have confirmed that, by using datanucleus-enhancer-1.1.2[1],
Scala can use JPA/JDO on GAE/J without writing any entity classes in Java.

[1] http://sourceforge.net/project/showfiles.php?group_id=222750&package_id=270301

刘浩

unread,
Apr 20, 2009, 10:24:28 AM4/20/09
to lif...@googlegroups.com
Thanks a lot.

I will try.

2009/4/20 Atsuhiko Yamanaka <atsuhiko...@gmail.com>

Atsuhiko Yamanaka

unread,
Apr 20, 2009, 10:40:08 AM4/20/09
to lif...@googlegroups.com
Hi,

On Mon, Apr 20, 2009 at 11:24 PM, 刘浩 <sniper...@gmail.com> wrote:
> Thanks a lot.
>
> I will try.

I want to share my Author.scala and Book.scala for further references.
I have pasted them at
http://gist.github.com/98561

Amit Kumar Verma

unread,
Jun 8, 2009, 3:09:28 AM6/8/09
to Lift
Hi All,

I have made a simple test project http://testinggwe.appspot.com/ . For
new development it good we can use Datastore and JPA but can we deploy
existing project on GAE.

Thanks & Regards
Amit Kumar Verma

On Apr 20, 7:40 pm, Atsuhiko Yamanaka <atsuhiko.yaman...@gmail.com>
wrote:
> Hi,

marius d.

unread,
Jun 8, 2009, 6:57:35 AM6/8/09
to Lift
Out of curiosity have you tried JDO with GAE? Does anyone have a
simple example?

Br's,
Marius

On Apr 11, 10:53 am, Atsuhiko Yamanaka <atsuhiko.yaman...@gmail.com>
wrote:
> Hi,
>
> On Fri, Apr 10, 2009 at 10:03 PM, David Pollak
>
> <feeder.of.the.be...@gmail.com> wrote:
> > Thank you! Thank you! Thank you!
> > I'd like to kiss you (but my wife might get upset)
> > Next time you come to the Bay Area, I will buy you lunch or dinner!
>
> If I get an opportunity to be there in the future, I'll want to enjoy
> lunch with you!
>
> > On Apr 10, 2009 1:46 AM, "Atsuhiko Yamanaka" <atsuhiko.yaman...@gmail.com> wrote:
> > As a proof of concept, I have succeeded to run lift-example on GAE/J,  it is running at
> >  http://lift-example.appspot.com/index
>
> > Of course, CometAcotr is not functional, and DB is not available
> > because of jdbc usage.
> > In this weekend, if possible, I will try JPA.
>
> > Here is a fork of liftweb source code to run lift-example on GAE/J,
> >  http://github.com/ymnk/liftweb/tree/master
>
> It seems that JDBC API must not have be forbidden on GAE/J .
> I have succeeded to use H2 mem db by updating to its latest version[1] and
> now DB functionalities have worked on
>  http://lift-example.appspot.com/index
>
> However, it is not adequate for the practical usages, of course.
> FYI, I found an interesting message[2] about a plan to implement
> "JDBC to com.google.appengine.api.datastore wrapper"
>
> PS. I will add CC to lif...@googlegroups.com and further discussions
> should be there.
>
> [1]http://www.h2database.com/html/changelog.html
> [2]http://groups.google.com/group/google-appengine-java/msg/71278bbee901...
Reply all
Reply to author
Forward
0 new messages