简体   繁体   English

JSF 2.0 AJAX调用失败

[英]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. 我正在做一个项目,以使用JSF1.2,JSP,Struts,Tiles,Richfaces来使用现有项目……仅使用JSF2.0,内置facelets支持并将Richfaces更新到版本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. 我正在尝试将以前使用<a4j:support>标记处理的AJAX组件更新为<f:ajax>标记,而不是按照我希望的方式工作,我遇到了一个错误,我只能解释因为我忘记了一切配置方面的东西。

It's a NullPointerException being thrown in com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter() method. 这是在com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter()方法中引发的NullPointerException。

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. 当我尝试激活所述组件上的AJAX事件时,它会崩溃。 I get an error, and nothing updated via AJAX. 我收到错误消息,并且没有通过AJAX更新任何内容。 It's happening with every AJAX component I try to convert. 我尝试转换的每个AJAX组件都在发生这种情况。 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. 我不知道这是否相关,但是我在该代码中引用的Bean现在被注释为ala JSF2.0并已从faces-config.xml中删除,但是,我还没有完全摆脱掉faces- config.xml中。 Still working on converting everything. 仍在努力转换所有内容。 Also, I'm running this on Tomcat 6.0. 另外,我正在Tomcat 6.0上运行它。

Any help, suggestions would be greatly appreciated. 任何帮助,建议将不胜感激。 I'm really stuck on this problem. 我真的陷在这个问题上了。

EDIT 1: 编辑1:

Using mojarra version 2.1.1 as per the bundle title I downloaded. 按照我下载的捆绑包标题使用mojarra 2.1.1版。 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. 编辑2:因此,尝试“最小化”页面会产生相同的结果,相同的错误。

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. 编辑3:好的,用行号更新了贫民窟堆栈跟踪。 You guessed right on the line number in the first class to toss the error: http://pastebin.com/49yUDcPM 您在第一个类的行号上猜对了,就抛出了错误: http : //pastebin.com/49yUDcPM

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

test page I created for BalusC's at suggestion: http://pastebin.com/kSeUyj7g 我在建议下为BalusC创建的测试页: http//pastebin.com/kSeUyj7g

EDIT 4: 编辑4:

http://tinypic.com/r/2dca0yo/7 http://tinypic.com/r/16jet7s/7 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. 这是WAR的WEB-INF / lib文件夹中当前打包的lib的图像。 Previous programmer included a lot of junk that I haven't cleaned out yet. 以前的程序员包括很多我还没有清除的垃圾。 Likewise, not sure where struts JARs are coming from. 同样,不确定struts JAR的来源。 Deleted any pre-dist JARs I could find relating to strusts or tiles. 删除了我可以找到的与strust或tile相关的所有pre-dist JAR。

EDIT 5: 编辑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." 这个评论带来了一个与众不同的世界:“同样,不确定struts JAR来自何处。删除了我可以找到的与strust或tile相关的所有pre-dist JAR。”

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. 显然,这不仅仅是我忘记删除的一个lib,而是我忘记删除的一个lib,然后在删除之后清理EAR。 AJAX requests are now properly going through, and I can see in the debugger values being re-bound as the request comes through! AJAX请求现在可以正常处理了,我可以看到调试器中的值在请求通过时被重新绑定! Load of other problems, but can manage those in my own time. 大量其他问题,但可以自己解决。 BalusC, you led me to this solution; BalusC,您使我想到了这个解决方案; if you want to submit an answer I'll gladly accept it! 如果您想提交答案,我会很乐意接受!

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

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). 此异常表明JSF视图根为null,这反过来又表明,在类路径中有一些针对JSF 1.2的第三方或自定义ViewHandler ,这并非完全适合JSF 2.0,因此也需要升级(或完全删除)。

Based on your screenshot with the overview of all JARs, the struts-faces JAR is the main suspect. 根据您的屏幕快照以及所有JAR的概述, struts-faces JAR是主要的可疑对象。 But those mixed versions of Apache Commons and JSTL libraries also doesn't look right. 但是,Apache Commons和JSTL库的混合版本看起来也不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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