0

I have a simple JSF 2.0 xhtml page that will not render when I insert an h:form tag. I can use a normal tag and things render just fine.

Here's my specs: - Java 1.6 - WebSphere 8.0.0.5 & its built-in Apache MyFaces 2.0.4 - PrimeFaces 3.4.2 - OmniFaces 1.3 - I have to support HTML 5 tags, so I'm using

Here's the simple test page:

<!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>

I've also tested this test page using NetBeans and Tomcat 7 with MyFaces 2.0.4 listed as a dependency and the PrimeFaces and OmniFaces depencies taken out of my pom to make sure that neither is causing the problem. The page still won't render.

Note that changing the DOCTYPE to the typical:

<?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">

is also not working.

Here's the error:

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) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:258) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) at 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) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.NullPointerException: serialFactory at org.apache.myfaces.shared_impl.util.StateUtils.getAsByteArray(StateUtils.java:268) at org.apache.myfaces.shared_impl.util.StateUtils.construct(StateUtils.java:235) at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeViewStateField(HtmlResponseStateManager.java:120) at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.writeState(HtmlResponseStateManager.java:111) at javax.faces.render.ResponseStateManager.writeState(ResponseStateManager.java:67) at org.apache.myfaces.application.jsp.JspStateManagerImpl.writeState(JspStateManagerImpl.java:598) at javax.faces.application.StateManager.writeState(StateManager.java:200) at org.apache.myfaces.application.ViewHandlerImpl.writeState(ViewHandlerImpl.java:302) at javax.faces.application.ViewHandlerWrapper.writeState(ViewHandlerWrapper.java:65) at javax.faces.application.ViewHandlerWrapper.writeState(ViewHandlerWrapper.java:65) at org.apache.myfaces.shared_impl.renderkit.html.HtmlFormRendererBase.encodeEnd(HtmlFormRendererBase.java:179) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:626) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622) at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1320) at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59) at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239) ... 17 more

I've noticed that the problem was fixed in MyFaces 2.0.6. The problem is that I'm tethered to WAS v8's MyFaces 2.0.4. I need to use WAS v8's built-in CDI, so I can combine it with EJB 3.1. You can only use the built-in CDI with the built-in MyFaces (it says so in the WAS v8 manual).

Any suggestions for a workaround? Can I use a simple <form> tag instead? I don't see any MyFaces errors when I use the <form> tag.

Chris Harris
  • 1,329
  • 4
  • 17
  • 28
  • Please use an updated version of MyFaces. The latest version (2.0.16/2.1.11) is considered the most stable one until the moment. – lu4242 Feb 02 '13 at 00:16
  • 2.1 should be even better. 2.1.10 can be found in the maven repo – Karl Kildén Feb 02 '13 at 09:11
  • Well, if I could indeed use the latest 2.0/2.1 version of MyFaces, I would. Heck, I used Mojarra's JSf 2.2 for the POC of the app. I can't upgrade though. I'm stuck using WebSphere v8.0.5. If I want to take advantage of JEE 6's CDI, you have to use WAS 8's built-in MyFaces 2.0.4. Yes, I can override 2.0.4 via setting the classloader policy to PARENT_LAST or a Shared Library, but I lose the benefits of being able to use CDI. In WAS v8, it's their CDI implementation or nothing. You can't override it. I'm not using JSF 2.0 without CDI used in conjunction with EJB 3.1 and JPA 2. – Chris Harris Feb 02 '13 at 09:41
  • Correction, I'm using WAS v8.0.0.5. I would also like to add that adding a regular `
    ` tag is not the appropriate workaround. While the compiler will not complain about that tag's existence, JSF will render a warning message at runtime stating that a JSF form is required. I'm trying to figure out a workaround for this problem. One salvation is that WAS v8.0.0.6 comes out in April, though that does me no good at this current point in time.
    – Chris Harris Feb 05 '13 at 15:34
  • Ugh, nothing I'm trying is working so far. I stumbled upon this post: [link](http://stackoverflow.com/questions/1492863/jsf-myfaces-nullpointerexception-serialfactory) and this post: [link](http://wiki.apache.org/myfaces/Performance). I tried implementing the code specified in the MyFaces wiki after setting my javax.faces.STATE_SAVING_METHOD from server to client. I added the jboss-serialization and trove dependencies and the classes. I then added the web.xml context-para org.apache.myfaces.SERIAL_FACTORY and set it to the JBossSerialFactory (as located within my package structure). No luck – Chris Harris Feb 05 '13 at 18:10
  • WAS v8.0 has IBM-specific web.xml MyFaces context-param keyname for org.apache.myfaces.SERIAL_FACTORY. I consulted [link](http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.nd.iseries.doc%2Finfo%2Fiseriesnd%2Fae%2Ftweb_jsf.html). @Inject Sarcasm sarcasm; Wow...thanks, IBM! Thumbs up to you for choosing MyFaces 2.0.4... – Chris Harris Feb 05 '13 at 18:13
  • I should specify that by "no luck", I mean that the overriding JBossSerialFactory class isn't even called. I set a debug break point in RAD, and that class was never once called upon page rendering. – Chris Harris Feb 05 '13 at 18:17
  • O.K. I owe an apology to IBM (MyFaces 2.0.6 would have been nicer though). It turns out that the culprit was OmniFaces v1.3. I decided to try re-adding the PrimeFaces & OmniFaces dependencies back to the NetBeans 7.2/Tomcat 7 test app. The app's index page wouldn't load due to the serialFactory error. I removed OmniFaces, and the page loaded. I rinsed and repeated this process 3 times to ensure that results were consistently reproducible. I was then able to reproduce the problem using bulky RAD/WAS v8.0.0.5. I've tried OmniFaces 1.1, 1.2, 1.3. Will OmniFaces 1.4 fix this problem @BalusC? – Chris Harris Feb 05 '13 at 20:54

1 Answers1

0

It turns out that OmniFaces 1.3 was the culprit. BalusC has included that error on the OmniFaces known issues wiki page.

That's a shame. I was using OmniFaces for conditional loading of html5.js scripts for IE6-8. Looks like I'll be waiting until April for WAS v8.0.0.6.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Chris Harris
  • 1,329
  • 4
  • 17
  • 28
  • Can't you just bundle JSF in webapp's `/WEB-INF/lib` and set WAS classloading policy to "module" or "PARENT_LAST" (depending on WAS version)? – BalusC Feb 05 '13 at 23:44
  • Aye, I can do that (I do that in WAS v6.1), but the caveat is that I lose the ability to use WAS 8's CDI. – Chris Harris Feb 07 '13 at 02:03
  • Not used to the comments being submitted when hitting the Enter button... [Link 1](http://www14.software.ibm.com/webapp/wsbroker/redirect?version=matt&product=was-express-iseries&topic=cweb_cdi_integration) - "Only the default JSF implementation (based on MyFaces) is supported for use with CDI." [Link 2](http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/com.ibm.websphere.express.iseries.doc/info/iseriesexp/ae/cweb_cdi.html) - Check out the "Avoid trouble" blurb at the bottom. – Chris Harris Feb 07 '13 at 02:14
  • [Link 3](http://www.ibm.com/developerworks/forums/thread.jspa?threadID=346760) [Link 4](http://www.ibm.com/developerworks/forums/message.jspa?messageID=14885217) That is a shame. Anyhow, very nice to meet you btw after reading so many of your posts, edits, and comments over the years. Thanks for OmniFaces! – Chris Harris Feb 07 '13 at 02:26