You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Eivind Rønnevik <ei...@kadme.com> on 2009/05/28 10:21:37 UTC

[MyFaces] Does ELException consume/hide real exception cause?

Hi everybody,

I'm using myfaces core 1.2, and have a question when it comes to 
exception-handling in using El-expressions.

In some cases when a valueBinding is being resolved and there's 
"business logic" connected to it - if business level throws exception 
(might even be NullPointerException), that cause is never being logged - 
instead it' seems like the exception is being catched and an ELException 
is "thrown"/logged not containing information about the original cause.

A short example:

The exception I get might be something like "An error occurred while 
getting property xxxxxx from an instance of class com.some.project.MyClass"

I have a handler A (session scope) which holds a list of items B. The B 
items are kept in database, and are read once pr session when getter is 
called the first time. Whenever the user clicks the link to display list 
of items B - the handler checks too see if the list has been initialized 
(if it is not null) - if not the handler queries the database to fetch 
the items and then return a new list of items B. If for some reason the 
fetching fails (connection-problems or null pointer somewhere), the 
ELException that is thrown does not contain that information.

In my case I apply a different styleClass to a panelGroup holding this 
list depending on number of items, so the error I see in the log only 
relates to this:

/[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/Whereoil].[Faces 
Servlet]] Servlet.service() for servlet Faces Servlet threw exception/
/at org.apache.commons.el.Logger.logError(Logger.java:484)
        at org.apache.commons.el.Logger.logError(Logger.java:588)
        at org.apache.commons.el.ArraySuffix.evaluate(ArraySuffix.java:318)
        at 
org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
        at 
org.apache.commons.el.BinaryOperatorExpression.evaluate(BinaryOperatorExpression.java:154)
        at 
org.apache.commons.el.ConditionalExpression.evaluate(ConditionalExpression.java:147)
        at 
org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:386)
        at 
javax.faces.component.html._ComponentUtils.getStringValue(_ComponentUtils.java:36)
        at 
javax.faces.component.html.HtmlPanelGroup.getStyleClass(HtmlPanelGroup.java:68)/

I had a quick look at the source of ArraySuffix, and to my understanding 
it seems that exceptions thrown are converted into 
InvocationTargetExceptions, which are caught silently and the code just 
write log error statements to the log.   

It becomes very difficult to find out what is actually going on, and in 
some cases I have to flood my code with system.out.printlines just to 
try to see where it fails.

I'm not sure whether I should ask this question here or whether I should 
write to Apache Commons El mailing list? But I wanted to hear if others 
had some experience with same problems and if there were something to do 
about it.

Regards,

Eivind Roennevik