Using JSF 2 with Google App Engine
Join the DZone community and get the full member experience.Join For Free
Since last week I have been playing with Google App Engine (GAE) and some of the frameworks that we normally use in enterprise applications. After developing some basic servlets to get comfortable with appspot I decided to use JSF 2. I wanted to see how well it fits in GAE aware of the fact that there are quite a few caveats mentioned on GAE website regarding JSF. I followed the obvious steps mentioned on the help pages but I think they are a bit outdated.
I decided to compile a list that one can follow to successfully get JSF 2.0.1 (Mojarra) working on GAE 1.2.6. If you have followed steps provided elsewhere and are still getting the following errors beware that you might have missed one or more of the setting provided.
- Will it play in GAE - Gives of list of technologies which are supported on GAE
- Configuring JSF 2 in GAE - Configuration provided by Google but this doesn't work straightaway
- JSF 2 Compatibility Issues - Compatibility issues with JSF 2
- JSF 2 impl jar fix - Josh has kindly provided a fix for JSF impl jar which resolves the startup problem
- Follow the steps provided in the jsf configuration guide on GAE website (see Resources:2)
- Replace the jsf-impl.jar with provided on Josh's blog page . Stack trace fixed
WARNING: Error starting handlers Throwable occurred:
- Now you app should start up on dev box but it when you deploy it on GAE you will get the following stack trace (lower the level to debug or warning)
Nested in javax.servlet.ServletException: java.lang.RuntimeException: java.lang.ClassNotFoundException: void:
java.lang.RuntimeException: java.lang.ClassNotFoundException: void
- In order to fix the above exception make sure following configuration are in web.xml (These are recommendations from GAE JSF2 compatibility issues: see Resources:3)
<!-- Seems like GAE 1.2.6 cannot handle server side session management. At least for JSF 2.0.1 -->
<!-- Recommendation from GAE pages -->
- Finally, I have noticed that sometimes objects kept in session loose data. For instance, I created a session scoped managed bean called CustomerBean and added customer name and email to it. When I move to second view, the name and email address stored in the managed bean are lost. Now this happens only on appspot not on the dev server so I can't debug and I haven't yet figured out why it this happens. I am working on a strange hack which put a token key value in the session in every request which solves the issue but I am sure why.
If anyone has any clue why please post a comment.
Hopefully, these setting will get you started on your first JSF 2 app on Google App Engine.
Opinions expressed by DZone contributors are their own.