MyFaces 2.0.4无法呈现h:form标签

时间:2013-02-01 21:10:09

标签: html5 jsf-2 primefaces myfaces omnifaces

我有一个简单的JSF 2.0 xhtml页面,在插入h:form标签时不会呈现。我可以使用普通标签,事情就好了。

这是我的规格:   - Java 1.6   - WebSphere 8.0.0.5&它内置的Apache MyFaces 2.0.4   - PrimeFaces 3.4.2   - OmniFaces 1.3   - 我必须支持HTML 5标签,所以我使用

这是简单的测试页面:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>This is a test page</title>
</h:head>
<h:body>

    <h:form></h:form>
</h:body>
</html>

我还使用NetBeans和Tomcat 7测试了此测试页面,并将MyFaces 2.0.4列为依赖项,并从我的pom中取出PrimeFaces和OmniFaces依赖项,以确保两者都不会导致问题。该页面仍然无法呈现。

请注意,将DOCTYPE更改为典型值:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

也无效。

这是错误:

  

javax.faces.FacesException:java.lang.NullPointerException:serialFactory       at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)       at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)       在org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:258)       在javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)       在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)       在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)       在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)       在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)       在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)       在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)       在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)       在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)       在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)       at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:585)       在org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run(AprEndpoint.java:1813)       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)       在java.lang.Thread.run(Thread.java:722)   引起:java.lang.NullPointerException:serialFactory       at org.apache.myfaces.shared_impl.util.StateUtils.getAsByteArray(StateUtils.java:268)       在org.apache.myfaces.shared_impl.util.StateUtils.construct(StateUtils.java:235)       在org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeViewStateField(HtmlResponseStateManager.java:120)       在org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeState(HtmlResponseStateManager.java:111)       at javax.faces.render.ResponseStateManager.writeState(ResponseStateManager.java:67)       在org.apache.myfaces.application.jsp.JspStateManagerImpl.writeState(JspStateManagerImpl.java:598)       在javax.faces.application.StateManager.writeState(StateManager.java:200)       在org.apache.myfaces.application.ViewHandlerImpl.writeState(ViewHandlerImpl.java:302)       在javax.faces.application.ViewHandlerWrapper.writeState(ViewHandlerWrapper.java:65)       在javax.faces.application.ViewHandlerWrapper.writeState(ViewHandlerWrapper.java:65)       在org.apache.myfaces.shared_impl.renderkit.html.HtmlFormRendererBase.encodeEnd(HtmlFormRendererBase.java:179)       在javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519)       在javax.faces.component.UIComponent.encodeAll(UIComponent.java:626)       在javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)       在javax.faces.component.UIComponent.encodeAll(UIComponent.java:622)       在org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1320)       在org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)       在javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)       在javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)       在org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)       在org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)       ......还有17个

我注意到问题已在MyFaces 2.0.6中修复。问题在于我被拴在了WAS v8的MyFaces 2.0.4上。我需要使用WAS v8的内置CDI,因此我可以将它与EJB 3.1结合使用。您只能将内置CDI与内置的MyFaces一起使用(在WAS v8手册中这样说)。

有关解决方法的任何建议吗?我可以使用简单的<form>代码吗?当我使用<form>标记时,我没有看到任何MyFaces错误。

1 个答案:

答案 0 :(得分:0)

事实证明,OmniFaces 1.3是罪魁祸首。 BalusC在OmniFaces known issues wiki page上包含了该错误。

这太遗憾了。我正在使用OmniFaces为IE6-8条件加载html5.js脚本。看起来好像我要等到4月才能使用WAS v8.0.0.6。