Cocoon stack traces

Posted on Wed 03 August 2005
Update : stacktraces are getting better !

Cocoon is a powerful framework that allows you to quickly write sophisticated web applications without writing a single line of Java.

Now the problem is that errors that appear in a Cocoon applications produce Java exceptions, which must then be correlated to the non-Java source file that led the error to appear: XSLT, sitemap, templates, form definition, JavaScript code for the flowscript, etc.

Up to now, this wasn't always an easy task, and that made Cocoon look like a complicated beast. These times are over: I've started adding " Cocoon stacktraces" to the beast last monday!

Here's what the Cocoon error page provided in the sample webapp looks like now (in this sample, an unknow form widget is referenced in a page template):

But wait, there's more! This kind of error page should not be deployed in production, as it's very unfriendly to application users. Now won't we loose this precious information? No, because it's also in the Java stacktrace!

The located exceptions in Cocoon print hybrid stacktraces, starting with file locations and then the regular Java method call stack:
org.apache.cocoon.util.location.LocatedRuntimeException: Repeater "contacts contains no widget with id "first-name".
at file:/Users/sylvain/dev/
at resource://org/apache/cocoon/forms/generation/jx-macros.xml:60:117
at file:/Users/sylvain/dev/
at resource://org/apache/cocoon/forms/generation/jx-macros.xml:231:26
at file:/Users/sylvain/dev/
at resource://org/apache/cocoon/forms/generation/jx-macros.xml:34:23
at file:/Users/sylvain/dev/
at org.apache.cocoon.forms.formmodel.Repeater.generateWidgetLabel(
at org.apache.cocoon.forms.generation.JXMacrosHelper.generateRepeaterWidgetLabel(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke(
at org.apache.commons.jexl.parser.ASTMethod.execute(
at org.apache.commons.jexl.parser.ASTReference.execute(
at org.apache.commons.jexl.parser.ASTReference.value(
at org.apache.commons.jexl.ExpressionImpl.evaluate(
at org.apache.cocoon.generation.JXTemplateGenerator.getNode(
at org.apache.cocoon.generation.JXTemplateGenerator.getNode(
at org.apache.cocoon.generation.JXTemplateGenerator.execute(
All this stuff relies on a few new classes to handle locations, locatable objects and located exceptions.

Nice, isn't it? Bertrand likes it, and so does Ugo :-)

Vector graphics in JavaScript

Eclipse Lepido, Tools for Apache Cocoon milestone 1