I used the <f:websocket/>
tag in my project with mojarra 2.3.3 and in project stage 'Development' everything was working fine. But when the project was deployed on our QA system with project stage 'Staging', the client produced the JS error "'mojarra' not defined".
This is due to the jsf.js being loaded as a blank file. When I debugged, I found that in com.sun.faces.application.resource.ResourceHelper#getInputStreamFromClientInfo
the content of the js file is copied to a GZIPOutputStream which is never finished and thus nothing is written to the wrapped ByteArrayOutputStream (ll. 234-237), resulting in the empty response to my client.
In stage Development
the file is delivered uncompressed.
Is this a bug or am I missing something? Is there a configuration for this? Is there a workaround?
I tried setting com.sun.faces.compressJavaScript
to false
with no luck.
When I call GZIPOutputStream#finish()
on the stream before it's written to the ByteArrayInputStream in the debugger, the content of the input stream is correct and sent to the client. I also checked mojarra 2.3.8 but the code seems to be unchanged.
I expect the client to receive the correct js code. It doesn't necessarily have to be compressed.
Addition: The project is running on a Tomcat 8.5.14 with JDK1.8.0_161 and I'm using Primefaces (6.2). I created a miminal working example here which doesn't use Primefaces. It doesn't actually push anything into the websocket channel but the relevant thing here is the JS error when the index.xhtml is loaded. It's also tested with Java 1.8_202, Tomcat 8.5.37, Mojarra 2.3.8. It's working (loading the jsf.js that is) with Mojarra 2.2.14.