webtier@glassfish.java.net

Re: Debugging JSF2 / XHMTL pages

From: <webtier_at_javadesktop.org>
Date: Wed, 01 Sep 2010 15:01:49 PDT

Hi Andrew,

> I've fought this error as well. After debugging
> through the 2.0.3 source it initially appeared the
> UIViewRoot element was somehow turning up null.
> Hence the reason for the "null source" and empty
> component tree output in the web browser. After
> digging a little further, I discovered there was an
> exception being thrown in the DefaultFaceletCache
> class:
>
>
> public DefaultFacelet getMetadataFacelet(URL url)
> throws IOException {
> DefaultFacelet f = null;
>
> try {
> _metadataFaceletCache.get(url).getFacelet(); //
> Exception thrown here.
> } catch (ExecutionException e) {
> nwrapIOException(e);
> }
> return f;
> }
>
> In my case the exception was:
> "Error Parsing /sign_in.xhtml: Error Traced[line: 26]
> The element type "meta" must be terminated by the
> matching end-tag "</meta>"." However, the exception
> is subsequently swallowed and never sees the light of
> day.

I started my debugger and tried that out, also saw it getting thrown there, but what's more problematic I think is that on its way up the chain encounters a finally in com.sun.faces.lifecycle.RestoreViewPhase#execute (line 245 in 2.0.3)

[code]
        finally {
            deliverPostRestoreStateEvent(facesContext);
        }
[/code]

which in turn tries to get the view root to construct a PostRestoreStateEvent, and that one being null, it ends up delivering a rather unusable message to the user.

The constructor of PostRestoreStateEvent says:

[code]
     * <p class="changed_added_2_0">Instantiate a new
     * <code>PostRestoreStateEvent</code> that indicates the argument
     * <code>component</code> just had its state restored.</p>
[/code]

Given that when there's a problem in the XHTML tree, there's nothing much that can be restored, I'd say that it is probably safe to discard the firing of that event (e.g. by doing a null check on the view root prior to calling the method in the finally block). But I don't know what the spec says there, would have to look it up.

> Long story short -- XHTML requires all tags to be
> terminated, and in my case, the <meta> tag wasn't.
> Terminating the tag corrected the issue.

Sure, but then again as Mojarra user I would like to get the error message telling me where I messed up (especially when you get this kind of beast for the first time, it's a bit distressing).

Will try to find some time this week-end and make a unit test that demonstrates that case (if it wasn't already reported and fixed).

Cheers,

Manuel
[Message sent by forum member 'manuelbernhardt']

http://forums.java.net/jive/thread.jspa?messageID=481623