musings of a Software Developer

Finally JSF 1.2 and Facelets on Websphere 6.1.


Well today I re-tried to get JSF 1.2 and facelets to work on websphere 6.1 and after some struggling I finally got it to work.

The things I mentioned in my last post where instability and some problems with validators with arguments. The first part must have been a class-loader problem, or maybe a problem with myfaces 1.2 on websphere because today I tried the JSF-RI and it worked.

One example of a custom validator that did not work was:

<h:input value="#{bla}" id="bla" >
    <ns:validator field1="test"/>

the problem was that in the validation phase the validator lost the field1 value. In fact this problem was caused by the default jsf version of websphere. It created a validator without implementing the StateHolder interface, and so I did not save and restore state in validators. Even on components the save and restore state were apparently not used like in jsf 1.2 (1 component also lost a value binding after putting jsf 1.2 in it). When you implement this interface in your validators and make sure you always have valid methods for saving and restoring state this problem is solved.

So the steps to get JSF 1.2 with facelets working on Webspere 6.1 are the following:

  1. Create a dir with the following jars:
    • jsf-api.jar
    • jsf-impl.jar
    • el-api-1.0.jar (from facelets)
    • el-impl-1.0.jar (from facelets)
  2. Create a shared library with those jars in the classpath.
  3. Create a classloader with application classes loaded first(Parent last) on server level with a binding to that shared lib.
  4. Make sure that all of your converters, validators and component that take arguments implement the StateHolder interface.
  5. Eventualy you might need to create the following files in the META-INF/services directory of your web-app:(if the dir services does not exist just create it.
    1. javax.faces.application.ApplicationFactory with content: com.sun.faces.application.ApplicationFactoryImpl
    2. javax.faces.context.FacesContextFactory with content: com.sun.faces.context.FacesContextFactoryImpl
    3. javax.faces.lifecycle.LifecycleFactory with conent: com.sun.faces.lifecycle.LifecycleFactoryImpl
    4. javax.faces.render.RenderKitFactory with content: com.sun.faces.renderkit.RenderKitFactoryImpl
  6. done!

This works on Websphere, on and later versions untill this version, facelets won’t work cause of a bug in websphere.

Next on my list: myfaces 1.2!

Update: added the factory files.

Leave a Reply

Required fields are marked *.