Wednesday, April 08, 2009

JSF on Google App Engine

OK, so Java on GAE is straight forward. See the previous post for a quick demo using GWT.

How about JSF? Hmm, not as straight forward if you are trying to use JSF 1.2 and MyFaces. In fact, I can't get it to work. I get as far as this error:

java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
at
org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:60)

Which would suggest that there is something wrong with the version of JSP that is being used? GAE uses Jetty under the covers, but I'm not sure which version. I would have thought it was a version that supports JSP 2.1, but who knows. The SDK comes with Geronimo JSP 2.1 and Servlet 2.5 jars, so you would think it would work.

Anyhoo, JSF works with MyFaces 1.1 and you can see a quick demo here. It doesn't do much at the moment, but I'll play around with it and see if I can do something a little better.

I have a Java/Swing application that uploads old Polar HRM data to the new Polar web site. This is an ideal application to convert to JSF/Facelets/RichFaces and host on GAE. Watch this space (well, come back in a few months ;) )

8 comments:

  1. I want to use ajax4jsf,but i get error :"java.lang.NullPointerException
    at org.ajax4jsf.framework.resource.InternetResourceService.serviceResource(InternetResourceService.java:116)";

    ReplyDelete
  2. Haven't tried ajax4jsf yet. That was one of my next steps. I'll post if I get it working or not.

    ReplyDelete
  3. Is Richafaces works on appspot ?
    it Works fine in my machine to the local adress.
    I had that stacktrace in the log of appspot:

    rg.apache.myfaces.webapp.StartupServletContextListener initFaces: Error initializing ServletContext
    javax.faces.FacesException
    at javax.faces.FactoryFinder.newFactoryInstance(FactoryFinder.java:194)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:140)
    at org.apache.myfaces.config.FacesConfigurator.configureRenderKits(FacesConfigurator.java:927)

    Please, i need help

    ReplyDelete
  4. I didn't get RichFaces to work - see this post -> http://rikara.blogspot.com/2009/04/jsf-and-richfaces-on-google-app-engine.html

    This thread -> http://code.google.com/p/googleappengine/issues/detail?id=1258 has some discussion on JSF issues in general.

    The GAE forum has some more comments on JSF/RichFaces issues -> http://groups.google.com/group/google-appengine-java/search?group=google-appengine-java&q=JSF+richfaces&qt_g=Search+this+group

    ReplyDelete
  5. Maybe this project can help you.

    http://code.google.com/p/jsfongap/

    ReplyDelete
  6. App Engine support is there for JSF since MyFaces 2.0.

    You can take a look at http://myfaces.apache.org/core20/googleappenginesupport.html

    It would be great if you can edit your post and add a footnote.

    Cheers,

    ReplyDelete
  7. Cool, thanks for that. I've some time on my hands on the next week or two so may revisit this.

    ReplyDelete