Migrating to Myfaces 1.2

Decorating FacesServlet: More often than not, an enterprise application would require having its business core initialized on Web Server startup and before it can service the first request. The Servlet *init* method is mostly the placeholder to trigger the business core initialization. For that matter, it is quite a frequent practice to decorate the Startup Servlet and call the initializer block from the Servlets init(ServletConfig config) method. In a JavaServer Faces application, the startup Servlet is the javax.webapp.FacesServlet. Decorating a FacesServlet would have worked just fine for you in the earlier versions of JSF (till 1.1). In JSF 1.2, this is no longer the case. If your web.xml do not have the javax.webapp.FacesServlet Servlet mapping entry, your web application will fail to start. How do you go about it?

Well, there is an option. If you are using MyFaces implementation of JSF 1.2 (I use MyFaces1.2.3), your previous decorator Servlet should extend from org.apache.myfaces.webapp.MyFacesServlet. Well, I admit that inheritance is evil. If I find a better way to still work with decorator pattern, I will certainly post the updates here.



Client-side State Saving:

If your JSF web application employs Client-side state saving, you are more than likely to get a "javax.crypto.BadPaddingException: Given final block not properly padded"

Encryption of client-side state saving is supposed to be OFF unless you explicitly enable it, but is in fact ON unless you DISABLE it!

The problem is that if you don't specify a secret (because you think you're not using encryption), MyFaces will generate one and place it in application context; but this will change when you redeploy, and the secret used in pages in users' browsers from before the redeploy will then fail.

To get rid of the error, add the following <context-param> to your web.xml file:

<context-param>

<param-name>org.apache.myfaces.USE_ENCRYPTION</param-name>

<param-value>false</param-value>

</context-param>

See http://www.mail-archive.com/users@myfaces.apache.org/msg45187.html for further details

Of course, don't forget to modify your web.xml to web-app_2_5.xsd





Reactions: 

1 comments:

cecchisandrone said...

Thank you...it worked for me!