1

The application seemed to start fine but I am now plagued by empty strings being applied to view parameters. javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL parameter was already set to true in my web.xml.

Here's what I did to upgrade:

  1. Updated JSF artifacts: from javax.faces:javax.faces-api:2.2 and org.glassfish:javax.faces:2.2.15 to javax.faces:javax.faces-api:2.3 and org.glassfish:javax.faces:2.3.8.
  2. Updated namespace in faces-config.xml.
  3. Updated namespace in beans.xml to enable 2.0.
  4. Updated web.xml to servlet 4.0.
  5. Added javax.faces.ENABLE_CDI_RESOLVER_CHAIN and javax.faces.ENABLE_WEBSOCKET_ENDPOINT in web.xml.
  6. I even added a JSF 2.3 activator class even though it seemed as if it was redundant.
  7. OmniFaces updated from 2.6.9 to 3.2.

EDIT: Turns out this is related to Tomcat 8 (and 9) coerce behaviour, null strings are incorrectly set as empty strings

But as stated in the title I'm trying to migrate to JSF 2.3 on Tomcat 9 (9.0.12). The previous question and BalusC blog does not directly address this case. I should also state that the application was running on JDK11 without problems before this.

From the previous question I learned the using Oracles EL implementation could work but I'm getting:

java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 16 out of bounds for byte[9]
at java.base/java.lang.System.arraycopy(Native Method)
at com.sun.faces.util.ByteArrayGuardAESCTR.decrypt(ByteArrayGuardAESCTR.java:157)
at com.sun.faces.context.flash.ELFlash$PreviousNextFlashInfoManager.decode(ELFlash.java:1414)
at com.sun.faces.context.flash.ELFlash.getCurrentFlashManager(ELFlash.java:1237)
at com.sun.faces.context.flash.ELFlash.doPrePhaseActions(ELFlash.java:641)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:98)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:133)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:201)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:670)
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
matsa
  • 346
  • 5
  • 16
  • What about your EL versions? – Kukeltje Dec 13 '18 at 10:00
  • I've not touched that as it was not part of my Gradle build files. Isn't EL bundled by Tomcat? – matsa Dec 13 '18 at 10:02
  • it is, but if you included something in your own project it might have played a role. – Kukeltje Dec 13 '18 at 10:16
  • Related? https://stackoverflow.com/questions/33334192/tomcat-8-coerce-behaviour-null-strings-are-incorrectly-set-as-empty-strings ??? I found this by posting "tomcat 9 javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL site:stackoverflow.com" in a searchengine https://www.google.com/search?q=tomcat+9+javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL – Kukeltje Dec 13 '18 at 10:17
  • That seems REALLY relevant. My first reaction is that I was already on Tomcat 8.5 without this being a problem, but I'll check this out right away. – matsa Dec 13 '18 at 10:20
  • BalusC tries to summarize his findings in http://balusc.omnifaces.org/2015/10/the-empty-string-madness.html but there's no specific mention of JSF 2.3. I did not have this problem with JSF 2.2. – matsa Dec 13 '18 at 10:59
  • Yes I know... Still, did it fix it for you? Then maybe we can 'ping' @BalusC to update his blog – Kukeltje Dec 13 '18 at 11:59
  • Maybe you should create a 'new' question. about the 'upgrade or usage' of the Oracle EL (which version btw???) – Kukeltje Dec 13 '18 at 12:40
  • I'm also facing this problem now. Wildfly 16 bundled with Mojarra 2.3.9. + JDK 11 – erickdeoliveiraleal Mar 14 '19 at 14:58

1 Answers1

-1

In your web.xml, include:

<context-param>
    <param-name>
        javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
    </param-name>
    <param-value>
        **false**
    </param-value>
</context-param>
NKSM
  • 5,422
  • 4
  • 25
  • 38