your first Lift application on GAE/J

435 views
Skip to first unread message

Atsuhiko Yamanaka

unread,
Apr 22, 2009, 4:39:27 AM4/22/09
to lif...@googlegroups.com
Hi there,

Let me introduce you the brief tutorial to deploy simple lift application to
Google App Engine for Java(GAE/J) . Now, Lift 1.1-SNAPSHOT code base
has included the support for GAE/J and it has become very easy to do it.

First of all, suppose that you have already signed up GAE/J account
and registered your application name as, for example, lift, at your
admin page[1]
So, at the end of this tutorial, your application will be available at
http://lift.appspot.com/

Ok, let's start it.

1. Create the project.
As an example, we will create the project with the groupId as
'test.test.test' and
artifactId as 'test'. So it should be done as follows,

mvn archetype:create -U \
-DarchetypeGroupId=net.liftweb \
-DarchetypeArtifactId=lift-archetype-blank \
-DarchetypeVersion=1.1-SNAPSHOT \
-DremoteRepositories=http://scala-tools.org/repo-snapshots \
-DgroupId=test.test.test -DartifactId=test

Please note that artchetypeVersion is '1.1-SNAPSHOT' and
remoteRepositories is
'http://scala-tools.org/repo-snapshots'.
It seems it will fail If it is 'http://scala-tools.org/repo-releases'

2 Add appengine-web.xml
Create a file named as 'appengine-web.xml' under 'src/main/webapp/WEB-INF'
with your faivorite editor.

$ cd test
$ emacs -nw src/main/web/app/WEB-INF/appengine-web.xml

Its content should be as follows,

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>lift</application>
<version>1</version>
<system-properties>
<property name="in.gae.j" value="true" />
</system-properties>
<sessions-enabled>true</sessions-enabled>
<static-files>
<exclude path="/**" />
</static-files>
</appengine-web-app>

Please note that the content of application tag must be the application name
you have registered. In this tutorial, we have used 'lift' as
described previous.
And then, one more note. Without 'static-files' tag setting, you
will get weired result at
http://lift.appspot.com/index.html ; I mean that the content of
/index.html will be displayed
without snippet processing.

3. Compile
As you have done every day, you will be able to compile it.

$ mvn package

4. Testing
Google App Engine for Java SDK[2] has included the local development server.

$ appengine-java-sdk-1.2.0/bin/dev_appserver.sh target/test-1.0-SNAPSHOT

After some messages, it will wait for your access at
http://localhost:8080/ .
Try it with your web browser.

5. Deployment
It is really easy to deploy it to GAE/J.

$ appengine-java-sdk-1.2.0/bin/appcfg.sh update target/test-1.0-SNAPSHOT

You will be asked for your email address on GMAIL and password for it.
If everything works well, your first lift application must be available at
http://lift.appspot.com/

That's all.

The comet and RDB accesses are not available on GAE/J, but Lift's
nice functionalities
like snippet, ajax, etc. are available and it is worth of trying it, IMHO.
If it is allowed, I'll post other tutorials, for example, for Lift/JPA
and some tips to
run Lift on GAE/J and to work around some GAE/J's bugs.

Frankly to say, in Lift code base, there must be many problems and
bugs to run it there.
I hope that this tutorial becomes the first step for Lift users to try GAE/J
and contribution for finding, sharing and fixing bugs and problems.


[1] http://appengine.google.com/
[2] http://code.google.com/intl/en/appengine/downloads.html#Google_App_Engine_SDK_for_Java


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/

Derek Chen-Becker

unread,
Apr 22, 2009, 10:18:07 AM4/22/09
to lif...@googlegroups.com
Nice!

刘浩

unread,
Apr 22, 2009, 10:51:18 AM4/22/09
to lif...@googlegroups.com
Thanks.

Maybe you also could put it in Wiki.

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

Peter Bliznak

unread,
Apr 22, 2009, 11:39:27 AM4/22/09
to lif...@googlegroups.com
That's good stuff!

I would never acutally think of putting real-life enterprise app onto GAE/J
but for fun it might work well

You mentioned you have more examples, I would be especially interested
in Lift/JPA. You should put them all on WIKI somewhere.

Peter.


From: Atsuhiko Yamanaka <atsuhiko...@gmail.com>
To: lif...@googlegroups.com
Sent: Wednesday, April 22, 2009 4:39:27 AM
Subject: [Lift] your first Lift application on GAE/J

dramsay

unread,
Apr 22, 2009, 11:44:56 AM4/22/09
to Lift
This is great. +1 to Derek's suggestion to put it in the wiki.

On Apr 22, 4:39 am, Atsuhiko Yamanaka <atsuhiko.yaman...@gmail.com>
wrote:
> [2]http://code.google.com/intl/en/appengine/downloads.html#Google_App_En...

David Pollak

unread,
Apr 22, 2009, 12:10:27 PM4/22/09
to lif...@googlegroups.com
Freekin' awesome stuff!

Please keep it coming!

Rock and Roll!
--
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

Eric Daugherty

unread,
May 15, 2009, 9:33:11 PM5/15/09
to Lift
I think I executed all the steps correctly, but when I deploy it to
GAE I get a Security Access Control Exception because the Actor class
is trying to create a thread I think. Is there something I have to do
to disable the Actors in Lift. I know GAE does not support any Thread
manipulation but I just build the default app as described above and
deployed. It worked fine locally in the GAE Dev Environment.

Stack trace:

Uncaught exception from servlet
java.lang.ExceptionInInitializerError
at scala.actors.Actor$class.scheduler(Actor.scala:374)
at net.liftweb.http.PointlessActorToWorkAroundBug$.scheduler
(LiftServlet.scala:658)
at scala.actors.Actor$class.start(Actor.scala:781)
at net.liftweb.http.PointlessActorToWorkAroundBug$.start
(LiftServlet.scala:658)
at net.liftweb.http.PointlessActorToWorkAroundBug$.ctor
(LiftServlet.scala:721)
at net.liftweb.http.PointlessActorToWorkAroundBug$.<init>
(LiftServlet.scala:729)
at net.liftweb.http.PointlessActorToWorkAroundBug$.<clinit>
(LiftServlet.scala)
at net.liftweb.http.LiftRules$.<init>(LiftRules.scala:50)
at net.liftweb.http.LiftRules$.<clinit>(LiftRules.scala)
at net.liftweb.http.LiftFilter.init(LiftServlet.scala:581)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:
99)
...
Caused by: java.security.AccessControlException: access denied
(java.lang.RuntimePermission modifyThreadGroup)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at com.google.apphosting.utils.security.SecurityManagerInstaller
$CustomSecurityManager.checkAccess(SecurityManagerInstaller.java:72)
at java.lang.ThreadGroup.checkAccess(Unknown Source)
at java.lang.Thread.init(Unknown Source)
at java.lang.Thread.<init>(Unknown Source)
at scala.actors.FJTaskScheduler2.<init>(FJTaskScheduler2.scala:26)
at scala.actors.Scheduler$.<init>(Scheduler.scala:30)
at scala.actors.Scheduler$.<clinit>(Scheduler.scala)
...


On Apr 22, 3:39 am, Atsuhiko Yamanaka <atsuhiko.yaman...@gmail.com>
wrote:
> Hi there,
>
> Let me introduce you the brief tutorial to deploy simple lift application to
> Google App Engine for Java(GAE/J) . Now, Lift 1.1-SNAPSHOT code base
> has included the support forGAE/J and it has become very easy to do it.
>
> First of all, suppose that you have already signed upGAE/J account
> The comet and RDB accesses are not available onGAE/J,  but Lift's
> nice functionalities
> like snippet, ajax, etc. are available and it is worth of trying it, IMHO.
> If it is allowed, I'll post other tutorials, for example, for Lift/JPA
> and some tips to
> run Lift onGAE/J and to work around someGAE/J's bugs.
>
> Frankly to say, in Lift code base, there must be many problems and
> bugs to run it there.
> I hope that this tutorial becomes the first step for Lift users to tryGAE/J
> and contribution for finding, sharing and fixing bugs and problems.
>
> [1]http://appengine.google.com/
> [2]http://code.google.com/intl/en/appengine/downloads.html#Google_App_En...

Atsuhiko Yamanaka

unread,
May 16, 2009, 12:23:12 AM5/16/09
to lif...@googlegroups.com
Hi,

Thank you for your feedback.

On Sat, May 16, 2009 at 10:33 AM, Eric Daugherty <edaug...@gmail.com> wrote:
>
> I think I executed all the steps correctly, but when I deploy it to
> GAE I get a Security Access Control Exception because the Actor class
> is trying to create a thread I think.

It seems the recent commit[1] has caused that exception.
I have pushed the fix to the github repository.
May I ask you to try it again?

[1] http://github.com/dpp/liftweb/commit/9e39859be9b8f6f4fd7c17cf503b5bcfcd5e861a#diff-2

Eric Daugherty

unread,
May 16, 2009, 3:18:26 PM5/16/09
to Lift
Thank you! I redeployed it with the current SNAPSHOT version and the
base application now works fine.

Thanks,

Eric

On May 15, 11:23 pm, Atsuhiko Yamanaka <atsuhiko.yaman...@gmail.com>
wrote:
> Hi,
>
> Thank you for your feedback.
>
> On Sat, May 16, 2009 at 10:33 AM, Eric Daugherty <edaughe...@gmail.com> wrote:
>
> > I think I executed all the steps correctly, but when I deploy it to
> > GAE I get a Security Access Control Exception because the Actor class
> > is trying to create a thread I think.
>
> It seems the recent commit[1] has caused that exception.
> I have pushed the fix to the github repository.
> May I ask you to try it again?
>
> [1]http://github.com/dpp/liftweb/commit/9e39859be9b8f6f4fd7c17cf503b5bcf...

David Pollak

unread,
May 17, 2009, 11:45:11 PM5/17/09
to lif...@googlegroups.com
On Fri, May 15, 2009 at 9:23 PM, Atsuhiko Yamanaka <atsuhiko...@gmail.com> wrote:

Hi,

Thank you for your feedback.

On Sat, May 16, 2009 at 10:33 AM, Eric Daugherty <edaug...@gmail.com> wrote:
>
> I think I executed all the steps correctly, but when I deploy it to
> GAE I get a Security Access Control Exception because the Actor class
> is trying to create a thread I think.

It seems the recent commit[1] has caused that exception.
I have pushed the fix to the github repository.

Thank you very much for cleaning up after me! 

May I ask you to try it again?

[1] http://github.com/dpp/liftweb/commit/9e39859be9b8f6f4fd7c17cf503b5bcfcd5e861a#diff-2


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/


glenn

unread,
May 20, 2009, 2:28:27 PM5/20/09
to Lift
I like what you've accomplished with this. I tried to set this up from
the GAE side, using the GAE Eclipse plugin rather
than the maven lift archetype? I took all the 30+ jars the archetype
now installs and created a Eclipse User Library
that I put in the project classpath.

I then just put the lift filter in the web.xml file and ran it as a
Google Web Application.
Even though I built and used the snapshot from the github repository,
I still get the Security Access Control Exception.

There is another approach to mixing GAE and lift using the Eclipse
plugin. The documentation is here

http://code.google.com/eclipse/docs/existingprojects.html

I'm not sure how to run this, however. Do you just use mvn jetty:run,
or do you also need to launch the Google App Engine as well?
Have you tried it?

Glenn...

On May 15, 9:23 pm, Atsuhiko Yamanaka <atsuhiko.yaman...@gmail.com>
wrote:
> Hi,
>
> Thank you for your feedback.
>
> On Sat, May 16, 2009 at 10:33 AM, Eric Daugherty <edaughe...@gmail.com> wrote:
>
> > I think I executed all the steps correctly, but when I deploy it to
> >GAEI get a Security Access Control Exception because the Actor class
> > is trying to create a thread I think.
>
> It seems the recent commit[1] has caused that exception.
> I have pushed the fix to the github repository.
> May I ask you to try it again?
>
> [1]http://github.com/dpp/liftweb/commit/9e39859be9b8f6f4fd7c17cf503b5bcf...

Amit Kumar Verma

unread,
Jun 8, 2009, 10:38:56 AM6/8/09
to Lift
Hi Atsuhiko,

I trying the steps u have given but getting this error when execute
the STEP 3

$ mvn package

[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building test
[INFO] task-segment: [package]
[INFO]
------------------------------------------------------------------------
[INFO] [resources:resources]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [yuicompressor:compress {execution: default}]
[INFO] nb warnings: 0, nb errors: 0
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [scala:compile {execution: default}]
[INFO] Checking for multiple versions of scala
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [scala:testCompile {execution: default}]
[INFO] Checking for multiple versions of scala
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: /home/amit/scalaWorkspace/test/
target/surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running test.test.test.AppTest
[Fatal Error] :3:4: The markup in the document following the root
element must be well-formed.


Please advise, what could be the reason of this error.

And what is the meaning of STEP 4 and STEP 5

$ appengine-java-sdk-1.2.0/bin/dev_appserver.sh target/test-1.0-
SNAPSHOT

$ appengine-java-sdk-1.2.0/bin/appcfg.sh update target/test-1.0-
SNAPSHOT

where is this appengine-java-sdk-1.2.0 is located ???



Thanks & Regards
Amit Kumar Verma

Atsuhiko Yamanaka

unread,
Jun 8, 2009, 10:28:36 PM6/8/09
to lif...@googlegroups.com
Hi,

On Mon, Jun 8, 2009 at 11:38 PM, Amit Kumar Verma<cdac...@gmail.com> wrote:
> $ mvn package
...


> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running test.test.test.AppTest
> [Fatal Error] :3:4: The markup in the document following the root
> element must be well-formed.

I guess that the problem has happened in parsing your
src/main/web/app/WEB-INF/appengine-web.xml

That message says that the problem has occurred at line 3rd and column 4th.
Please check it again.

> And what is the meaning of STEP 4 and STEP 5
>
> $ appengine-java-sdk-1.2.0/bin/dev_appserver.sh target/test-1.0-
> SNAPSHOT
>
> $ appengine-java-sdk-1.2.0/bin/appcfg.sh update target/test-1.0-
> SNAPSHOT
>
> where is this appengine-java-sdk-1.2.0 is located ???

You can grab it at
http://code.google.com/intl/en/appengine/downloads.html#Google_App_Engine_SDK_for_Java
, and the latest version is 1.2.1 at the present time.


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

Skype callto://jcraft/

DFectuoso

unread,
Jun 21, 2009, 2:00:08 AM6/21/09
to Lift
You sir, you rock!!! Thanks for this awesome tutorial!

On Jun 8, 7:28 pm, Atsuhiko Yamanaka <atsuhiko.yaman...@gmail.com>
wrote:
> Hi,
>
>
>
> On Mon, Jun 8, 2009 at 11:38 PM, Amit Kumar Verma<cdac.a...@gmail.com> wrote:
> > $ mvn package
> ...
> > -------------------------------------------------------
> >  T E S T S
> > -------------------------------------------------------
> > Running test.test.test.AppTest
> > [Fatal Error] :3:4: The markup in the document following the root
> > element must be well-formed.
>
> I guess that the problem has happened in parsing your
>   src/main/web/app/WEB-INF/appengine-web.xml
>
> That message says that the problem has occurred at line 3rd and column 4th.
> Please check it again.
>
> > And what is the meaning of STEP 4 and STEP 5
>
> > $ appengine-java-sdk-1.2.0/bin/dev_appserver.sh target/test-1.0-
> > SNAPSHOT
>
> > $ appengine-java-sdk-1.2.0/bin/appcfg.sh update target/test-1.0-
> > SNAPSHOT
>
> > where is this appengine-java-sdk-1.2.0 is located ???
>
> You can grab it at
>  http://code.google.com/intl/en/appengine/downloads.html#Google_App_En...
Reply all
Reply to author
Forward
0 new messages