Saturday, August 22, 2009

It was really hard for me to find any information concerning annotations on default constractor. Finally I discovered that scala accepts the following syntax:class MyClass @Annotation() (val arg : Int) {}

It is important that an annotation is followed by (), otherwise parameters of MyClass are parsed as parameters of annotation...

Tuesday, August 18, 2009

The problem with Richfaces 3.3.1 and Sun JSF RI is that an exception thrown in action listener is suppressed by Richfaces. I will show why this happens. The following stacktrace shows an order of invocations that takes place when an action listener is called:

I've marked interesting places with ((1)), ((2)) and ((3)). The first interesting method is ((1)) - that is where we throw an unchecked exception. The exception will be catched somewhere between ((1)) and ((2)) and wrapped into the ELException class. Then this exception will be caught in ((2)) as it can be seen here (sources are taken from Sun JSF RI 1.2.12):

When the processActio methods catches exception it logs it and wraps exception cause into the AbortProcessingException. Here we come to place ((3)) which catches AbortProcessingException. The following is the source code from RichFaces 3.3.1.GA:

As you can see processEvents catches AbortProcessingException, logs it and does nothing! That is it!

I've tried a lot of solutions to solve this, I've tried to solve it with servlets/filters/phase-listeners/action-listeners and so on with no luck! Then I've solved it with last resort - AspectJ. The following aspect does the job perfectly:

Sunday, August 2, 2009

I upgraded existing project from Java 1.4 to Java 1.5, JSF 1.1 to JSF 1.2, myfaces to sun ri... and decided to leverage a framework providing AJAX for JSF. The first I tried was richfaces. But it worked unstable and I spent 2 days trying to find a reason for it. Then I tried to use trinidad. It was the same. The framework worked but very unstable. For example. I opened a jsf page, if I clicked on a ajaxfied button just immediately after page appeared, then button worked OK. But if I clicked on the button after a while, then the button didn't work, the relevant page part was not updated! It looked like a magick in work. Then I noticed a very strange message which I noticed long time ago but didn't pay any attention to it. The message was "INFO: Facelet[/page/blah.xhtml] was modified @ 14:23:24 AM, flushing component applied...". A quick investigation revealed a root of my problem! It turned out that time in a virtual machine I used as a place for application server was 3 hours less then current time! And so file creation time of files in WAR-file was greater than time in the virtual machine. It looked like facelets framework had some strange algorithm based on current time to reload modified files (and flush components tree). Having set facelets.REFRESH_PERIOD context parameter in web.xml I solved the problem. Both richfaces and trinidad worked fine after that.