GAE + PrimeFaces + Spring + Maven
Ok, the goal I was looking for here was to be able to have a personal (so not for work) development environment where I could write and host small applications in Java with a nice WEB 2.0 type interface. The final technology set I rested on (for many reasons not discussed here) was:
- Google App Engine (GAE) – for hosting
- Spring – for ease in server development
- JSF 2.0 – PrimeFaces – for nice GUI
- Maven – for build management
Looking around I couldn’t find any project that seemed to integrate these elements so I started with the following base projects and adjusted and hacked my way until I got something I was relatively happy with:
- Maven-GAE-plugin – http://code.google.com/p/maven-gae-plugin/
- Primefaces / Spring – prime-moviecollector – http://primefaces.googlecode.com/svn/examples/trunk/prime-moviecollector/
The end result of my integration effort can be found here:
http://gae-primefaces-spring-maven.appspot.com/
and the source here:
http://gae-primefaces-spring-maven.googlecode.com/svn/gae-primefaces-spring-maven
Things I don’t quite like at the moment and would still like to improve on are:
- Having to re-run with gae:run every time I make a small change. It would be much better if it was possible to do everything in Eclipse while still having a maven project. There are several people working on this so I will wait to see what initiatives come out of that.
- Not quite happy about having to use PrimeFaces 1. Not being a PrimeFaces expert I’m not sure what I am missing out on between the different versions but would of course liked to have integrated with the latest and greatest.
If you can assist on any of these please drop me a comment and I will endeavour to update the project.
For instructions on how to get it running and some of the errors I encountered along the way read on
Getting the sample running
Pre-conditions
You need Maven2 installed and some way to grab the code from the SVN repository.
To run locally
- Download project from Svn (basically a hard-earned POM) – SVN Location: http://gae-primefaces-spring-maven.googlecode.com/svn/gae-primefaces-spring-maven
- Kick off a “mvn gae:run” – This will run the application locally.
- Once this has completed use a browser and go to http://localhost:8080/
To run on GAE
- Setup an application on GAE
- Update the Pom.xml property <gae.application.appId> to be the same as the appId you setup on GAE.
- Kick off a “mvn gae:deploy” – Enter your login and password details when prompted.
- When finished go to http://<gae.application.appId>.appspot.com/ to view your PrimeFaces app online through GAE.
Some resources used
- Maven-GAE-plugin – http://code.google.com/p/maven-gae-plugin/
- Josh Carrier’s Blog providing the custom WebConfiguration class – http://javadocs.wordpress.com/2009/10/17/mojarra-jsf-2-0-rc2-and-google-app-engine-sdk-1-2-6/#more-242
- Primefaces site – http://primefaces.org
- Primefaces / Spring – prime-moviecollector – http://primefaces.googlecode.com/svn/examples/trunk/prime-moviecollector/
- Integrating GAE + JSF – https://sites.google.com/a/wildstartech.com/adventures-in-java/Java-Platform-Enterprise-Edition/JavaServer-Faces/sun-javaserver-faces-reference-implementation/configuring-jsf-20-to-run-on-the-google-appengine
- Integrating GAE + JSF – http://java.wildstartech.com/Java-Platform-Enterprise-Edition/JavaServer-Faces/sun-javaserver-faces-reference-implementation/configuring-jsf-12-to-run-on-the-google-app-engine
Problems Encountered
————————————————————————————
Error:
org.springframework.web.context.ContextLoader initWebApplicationContext: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.context.annotation.internalPersistenceAnnotationProcessor’: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/naming/NamingException
Solution: Don’t use the all in one spring package. Split it up.
————————————————————————————
Error:
java.lang.NullPointerException: No API environment is registered for this thread.
Solution:
must run “mvn gae:run”. I was running “mvn jetty:run” or “mvn tomcat:run”. I believe the reason this does not work is because it must setup the Data nucleus API environment and gae:run does this while of course the others don’t.
Tags: gae, Google App Engine, JSF, JSF 2.0, maven, primefaces, spring
You can comment below, or link to this permanent URL from your own site.
January 19, 2010 at 1:49 pm
Nice work! In current PrimeFaces-2.0.0-SNAPSHOT, facelets-taglib.xml should be fixed. In 2.0. RC there was a problem with that. You can try with a nightly build.
January 20, 2010 at 10:25 pm
Hi Cagatay,
I just tried again using version PrimeFaces-2.0.0-SNAPSHOT but still received the same error regarding the parsing of primefaces-p.taglib.xml
February 11, 2010 at 7:47 pm
Wow excellent work, Brendan!
I’ve been meaning to try this, but you beat me to it big time!
I don’t really have a problem with PrimeFaces. Actually I probably will prefer PrimeFaces due to its mobile / TouchFaces support.
Over time, RichFaces/IceFaces/Trinidad will come out of alpha and hopefully they’ll work with GAE too.
I’m grateful that you have good news with PrimeFaces and GAE, Brendan. 🙂
Regarding Maven, I agree with you. Without proper integrated development cycle, Maven development sucks big time.
I prefer using Maven Ant Tasks for dependency management for GAE, my build.xml is like this:
I still get some of Maven’s convenience while none of its inconveniences (using the same old Google App Engine for Eclipse development model).
February 11, 2010 at 7:49 pm
Haha, I knew my code will get screwed up.
For those interested, here it is: http://pastebin.com/f53b245b1
February 11, 2010 at 7:49 pm
P.S. Your app http://gae-primefaces-spring-maven.appspot.com/ now throws 500 Server Error 😦
February 12, 2010 at 10:28 am
Hi Hendy,
Thanks for the feedback. Regarding the 500 error I have seen it before but then it disappeared without me changing anything. I believe it is timing out when retrieving the data from data nucleus but I am unsure why this is happening and then only sometimes (see Exception below). It probably has something the way I am interacting with the data nucleus datastore. I cleared out the list of books people had entered and it seems to be working again.
Exception Sniplet:
com.sun.facelets.FaceletViewHandler handleRenderException: Error Rendering View[/bookList.xhtml]
com.google.apphosting.api.DeadlineExceededException: This request (12fbfc9a3e26c3d8) started at 2010/02/10 23:59:53.390 UTC and was still executing at 2010/02/11 00:00:22.162 UTC.
at java.util.LinkedList.getFirst(Unknown Source)
at org.datanucleus.store.appengine.DatastoreFieldManage
March 7, 2010 at 1:28 pm
For JSF 2 and PrimeFaces2, make sure you dont have FaceletViewHandler defined in faces-config.xml as it is standard now.
August 3, 2010 at 7:45 pm
cagataycivici,
Without the definition of a FaceletViewHandler the Primefaces components are not rendered at all. So it seems they do not hook in with the standard one automatically.
October 17, 2010 at 4:10 am
I have been trying to add Ajax support to this.But I get this ” Tag Library supports namespace: http://java.sun.com/jsf/core, but no tag was defined for name: ajax”.I am pretty new to JSF.Does JSF 2.0 not supprt Ajax?
October 22, 2010 at 10:11 pm
I’m using myfaces. When I run my app in Eclipse, there’s no problem. When I run it on appengine, I get:
Caused by: java.lang.RuntimeException: java.io.InvalidObjectException: enum constant attributes does not exist in class javax.faces.component.UIComponent$PropertyKeys
at com.google.apphosting.runtime.jetty.SessionManager.deserialize(SessionManager.java:413)
Any ideas?
February 17, 2011 at 2:38 am
Thank you! Nice job.
March 18, 2011 at 7:24 am
[…] https://eriahit.wordpress.com/2010/01/19/gae-primefaces-spring-maven/ LikeBe the first to like this post. […]
April 13, 2011 at 12:29 pm
Case you are using GAE + JSF, the follow link shows a solution:
http://www.patternizando.com.br/2011/04/erro-com-sun-faces-config-configurationexception-it-appears-the-jsp-version-of-the-container-is-older-than-2-1-and-unable-to-locate-the-el-ri-expression-factory/
August 2, 2011 at 9:47 am
Nice sample.
Do you have some tips / experience to share regarding GAE persistence layer?
March 2, 2012 at 1:07 pm
Nice one.
It s the first example I saw running on host.
I ve played with JSF only with localhost ’till now.
Probably it s the only way to have JSF free host right now.
Thx a lot. Gonna try it.
March 4, 2012 at 10:01 pm
Hai Brendan,
I tried this tutorial to get JSF running in google app engine
http://java.wildstartech.com/Java-Platform-Enterprise-Edition/JavaServer-Faces/javaserver-faces-20/configuring-javaserver-faces-20-to-run-on-the-google-appengine
But it doesn’t work.
Is there any tutorial you know just to setup the first hello world with google app, maven and jsf?
thx a bunch before
regards
July 8, 2013 at 11:13 pm
Tuaoridu uayevuma; Doctor Approved Prosolution Pills iyegazeu epuifveu enenayui rieauti yeoheyajo edegxanubi!
August 15, 2013 at 9:50 am
I just want to ask, what database you’re using here..?