javax.servlet.ServletException:WriteText方法无法写入空文本

时间:2012-11-16 04:41:12

标签: jsf

我使用 JSF + Icefaces + Richfaces + Primefaces 创建了一个Web应用程序。当我从eclipse作为项目运行它时它工作得很好但当我创建它的WAR文件并部署在GlassFish Server中时然后在渲染页面时抛出此异常

javax.servlet.ServletException: WriteText method cannot write null text

我搜索过但没有得到任何好的解决方案。快速的帮助非常受欢迎。

修改:1
我认为这将是这个的相关部分

                        <li class="page_item" id="liMasterSearch">      <!-- this is for hide (<li class="page_item hide" id="liMasterSearch"> applied to every class) -->
                            <h:commandLink value="Search" action="#{masterRenderBean.showSimpleSearch}"></h:commandLink>
                        </li>

                        <li class="page_item" id="liAdvanceSearch">
                            <h:commandLink value="Advance Search" action="#{masterRenderBean.showADVS}"></h:commandLink>
                        </li>

您可在此处看到两个链接(1)搜索 (2)高级搜索
当我点击搜索时,它会显示搜索页面(通过渲染 - 实际上我已将所有页面都包含在母版页中并在命令链接功能上渲染它们)

 <h:panelGroup rendered="#{not masterRenderBean.simpleSearch}">
            <ui:include src="../../WebPages/SearchPages/MasterSearch.xhtml"></ui:include>
            </h:panelGroup>

但是当我点击高级搜索链接(此部分应该呈现)时

<h:panelGroup rendered="#{not masterRenderBean.advs}">  
        <ui:include src="../../WebPages/SearchPages/PersonalAdvanceSearch.xhtml"/>
        </h:panelGroup>

浏览器显示上述异常 注意:请记住,在部署时会出现此问题。当我从代码中运行eclipse时,它不会进入实际应用程序

编辑:2 我在服务器日志中发现此异常是由于acefaces和这部分代码而来的

<ace:autoCompleteEntry id="txtplaceofbirth"
                                      rows="10" autocomplete="false" 
                                        minChars="2" width="150" 
                                        value="#{inputPersonal.selectedplcofBirth}" 
                                        filterMatchMode="none"  
                                       valueChangeListener="#{inputPersonal.valueChangeEventCity}">
                                        <f:selectItems value="#{inputPersonal.cities}"/>

                                        </ace:autoCompleteEntry></h:outputFormat>

搞砸了。任何想法为什么这是hapening?


编辑#3:
以下是异常的全部追踪痕迹

[#|2012-11-19T09:55:48.026+0500|SEVERE|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=53;_ThreadName=Thread-2;|java.lang.NullPointerException: WriteText method cannot write null text
    at org.icefaces.impl.context.DOMResponseWriter.writeText(DOMResponseWriter.java:314)
    at org.icefaces.impl.context.DOMResponseWriter.writeText(DOMResponseWriter.java:340)
    at com.sun.faces.renderkit.html_basic.OutputMessageRenderer.encodeEnd(OutputMessageRenderer.java:163)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at org.icefaces.impl.renderkit.RendererWrapper.encodeChildren(RendererWrapper.java:49)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
    at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at org.icefaces.impl.renderkit.RendererWrapper.encodeChildren(RendererWrapper.java:49)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
    at org.icefaces.impl.context.DOMPartialViewContext.processPartial(DOMPartialViewContext.java:142)
    at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:391)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
|#]

1 个答案:

答案 0 :(得分:0)

java.lang.NullPointerException: WriteText method cannot write null text
    at org.icefaces.impl.context.DOMResponseWriter.writeText(DOMResponseWriter.java:314)
    at org.icefaces.impl.context.DOMResponseWriter.writeText(DOMResponseWriter.java:340)
    at com.sun.faces.renderkit.html_basic.OutputMessageRenderer.encodeEnd(OutputMessageRenderer.java:163)

这首先是由Mojarra的一个错误造成的。 null的{​​{1}}值未正确处理。这被报告为issue 2351,自Mojarra 2.1.9以来已经修复。

显然,生产中的服务器正在运行旧版Mojarra。您有两个选择:

  1. 在生产服务器中升级Mojarra版本。 currently已经是2.1.14。
  2. 请确保<h:outputFormat>组件中的任何一个都没有获得<h:outputFormat>值,只有在值null时才有条件地呈现它。