Trap with System Properties

Recently I had developed a file upload module in a Portlet application. The module was tested and working perfectly in Windows.When the application was delpoyed in an AIX server, this fuctionality stopped working.
The fix was simple , though it took hours to debug.

To get the header of the multipart content I had code like this,
final int headerIndex= requestContent.indexOf(System. getProperty("line.separator") +System.getProperty("line.separator"));

Using this index I was trying to get the conetent and do the manipulation.

The server where the application was deployed "line.separator" was not set and System. getProperty("line.separator") was returning EMPTY STRING !!!.

This caused my logic to break in the server. So finally I had to put a empty string check (IF condition) for for the property ,line.separator and hard code as '\r\n' as i have no cotrol over the server setting.

This article is a good one for such traps while porting from Windows to AIX, http://www.ibm.com/developerworks/aix/library/au-aix-javatraps/index.html

Facelet - Flushing component

When deploying a new EAR created from a machine with time settings different from that of the server where application is deployed, flushing of the JSF components can happen.

Logs will show the following error.

INFO: Facelet[/pages/menu.jspx] was modified @ 11:45:04 AM, flushing component applied @ 11:41:30 AM

The reason being, when ever a new request is made, server sees the page as modifed in future time stamp and starts compiling again. This causes the component tree to be created again, causing to lose all the state stored by the component.

To fix this add facelets.REFRESH_PERIOD to the web.xml.

REFRESH_PERIOD indicates, When a page is requested, what interval in seconds should the compiler check for changes. If you don't want the compiler to check for changes once the page is compiled, then use a value of -1. Setting a low refresh period helps during development to be able to edit pages in a running application.

web.xml, should look like this,




-1 indicates not to check for changes, since production servers it is safe to set this value.

For more,
https://facelets.dev.java.net/nonav/docs/dev/docbook.html#config-webapp-init