Wednesday, 29 October 2014

debugging EL expressions in your application

Debugging java code is relatively simple. But sometimes the stack trace which you can get is unreadable. You see a lot of lines from the core of the framework and... nothing more. No additional hints where to search for the cause. But stack trace contains a lot of UI-related classes. The reason may be in the EL expression.

One approach is to comment all UI components on the page and check which expression generates an error.

Second approach is a try to trace processed EL expressions on the page. Pages are usually very complex and usually contain many EL...

It is possible to override the default EL resolver in your application. First of all, please create the class that extends abstract ELResolver class or one of its subclasses. In this example I've used MapELResolver (reasons why I've used it you'll find in the documentation).


Then point it in faces-config.xml, as shown below:


I've decided to override getValue method becasue usually an error will be thrown there.


Please note, that this is only a simple implementation that I've used to solve my problem. To fulfill the example, the page that will be examinated.


It bases on DEPARTMENTS table in HR schema. Finally, logs from the application after opening the page:


Hope it'll simplify your debugging processes in the future :)

2 comments:

  1. Note that with JDeveloper the ADF Debugger has a special capability to show you the value of Expression Language - https://blogs.oracle.com/shay/entry/introduction_to_the_adf_debugger

    ReplyDelete
  2. @shay
    it's true but it works only while your code stops at a breakpoint. in my case i've received ClassCastException while comparing two values. Stacktrace doesn't describe itself - a lot of framework calls. The page causing the exception weight approximately 200kb :)

    the idea is that in the log file from such huge page i'll thousands of unimportant data, one very important string and after that an exception.

    hope it clarifies better my intentions :)

    ReplyDelete