Search code examples
jsfrichfacesfacelets

Richfaces: NoSuchFieldElementException AjaxChildrenRenderer for HTML Tag


I use richfaces 3.3.3.Final with Seam and facelet.

I have plugged a profiler on my application and I have a weird behavior. When I log all exceptions thrown by the application, I have more than 10 000 NoSuchFieldElementException in 10 minutes.

After many search, I found the problem:

When I started an ajax request by a4j:support, the NoSuchFieldElementException is thrown by the AjaxChildrenRenderer in these lines (199-202):

String componentType = (String) component.getClass().getField("COMPONENT_TYPE").get(null);
result = _specialComponentTypes.contains(componentType);

The component variable is a UIInstructions and it has no "COMPONENT_TYPE" field. So, the exception is normal. This exception is thrown for each html block contained in my page. For example:

<h2>Test</h2>
<span></span>

When I reRender a block with html tag, the exception is thrown. I have very complex page, so I get many of this exceptions.

How I can do to avoid this exception ? May be a parser option to avoid to go in this class for html block.

Thanks for your help.


Solution

  • As a temporary solution, you could modify the source code to add an instanceof check which should skip that block and then ship the modified source code with your webapp. Ship it either as a single class with identical package/class name in web project itself (javadoc-document it properly), which would always have preference in classloading over the one in the JAR, or as a modified and rebuild JAR file.

    if (!(component instanceof UIInstructions)) {
        String componentType = (String) component.getClass().getField("COMPONENT_TYPE").get(null);
        result = _specialComponentTypes.contains(componentType);
    }
    

    As a lasting solution, you should report it as a performance issue to the RichFaces guys so that they get it fixed and release a new update, but I don't think that they will prioritize 3.3.x updates that much. I.e. it might take longer than you'd expect.