简体   繁体   中英

JSF 2.0 AJAX Calls Failing

I am working on a project to take an existing project using JSF1.2, JSP, Struts, Tiles, Richfaces ... to simply use JSF2.0, the built-in facelets support, and updating Richfaces to version 4.

So far things are going pretty well, except for one major road block. I am trying to update AJAX components that were previously being handled with the <a4j:support> tags, to the <f:ajax> tags and instead of working how I'd hope, I'm getting an error which I can only interpret as me having forgotten something in terms of configuring everything.

It's a NullPointerException being thrown in com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter() method.

When I load the page the first time, I can see in the debugger the component binding correctly to the backing value; the page loads without incident. It's when I try to activate the AJAX event on said component that it blows up. I get an error, and nothing updated via AJAX. It's happening with every AJAX component I try to convert. Here is one such example:

        <h:selectOneMenu
        value="#{userSession.selectedNetwork}"
        id="network"
        >
        <f:selectItems value="#{userSession.networkUIOptions}" />
        <f:ajax event="change" render="selectedStation edit_site_button add_site_button"/>
    </h:selectOneMenu>

I don't know if this is relevant or not, but the bean I'm referencing in that code is now annotated ala JSF2.0 and removed from faces-config.xml, however, I haven't completely gotten rid of faces-config.xml. Still working on converting everything. Also, I'm running this on Tomcat 6.0.

Any help, suggestions would be greatly appreciated. I'm really stuck on this problem.

EDIT 1:

Using mojarra version 2.1.1 as per the bundle title I downloaded. Having trouble getting exact stack trace. Logging doesn't seem to be working correctly after changing so many things. Will keep trying. Also will try simple page and report results.

EDIT 2: So, trying to 'minimal' page yielded the same results, same error.

Still couldn't get logging to work exactly right, so just did some ghetto logging. See below for something resembling a proper stack trace:

EDIT 3: Okay, updated ghetto stack trace with line numbers. You guessed right on the line number in the first class to toss the error: http://pastebin.com/49yUDcPM

doFilter function of NPNSessionFilter.java: http://pastebin.com/iwG0rcQ6

test page I created for BalusC's at suggestion: http://pastebin.com/kSeUyj7g

EDIT 4:

http://tinypic.com/r/2dca0yo/7 http://tinypic.com/r/16jet7s/7

Here are images of the libs currently packaged in the WAR's WEB-INF/lib folder. Previous programmer included a lot of junk that I haven't cleaned out yet. Likewise, not sure where struts JARs are coming from. Deleted any pre-dist JARs I could find relating to strusts or tiles.

EDIT 5:

Okay, breakthrough! This comment made a world of difference "Likewise, not sure where struts JARs are coming from. Deleted any pre-dist JARs I could find relating to strusts or tiles."

Cleaned ear, re-dist, and things work better now. Obviously it wasn't just some lib I forgot to remove, but a lib I forgot to remove, and then clean the EAR out after having removed. AJAX requests are now properly going through, and I can see in the debugger values being re-bound as the request comes through! Load of other problems, but can manage those in my own time. BalusC, you led me to this solution; if you want to submit an answer I'll gladly accept it!

NullPointerException at com.sun.faces.context.PartialViewContextImpl:PartialViewContextImpl.java:createPartialResponseWriter:441

This exception indicates that the JSF view root is null which in turn indicates among others that there's some JSF 1.2 targeted 3rd party or custom ViewHandler in the classpath which isn't doing its job entirely right for JSF 2.0 and thus needs to be upgrade as well (or removed altogether).

Based on your screenshot with the overview of all JARs, the struts-faces JAR is the main suspect. But those mixed versions of Apache Commons and JSTL libraries also doesn't look right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM