-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jakarta Faces 4.0 websocket jakarta.faces.push.PushContext fails to serialize objects in certain cases #26854
Comments
Hi, thanks for bringing this to our attention. If you have a WAR file you could also provide, that would be great. I'll investigate and see what I can do. Thanks! |
I created an issue here: https://issues.apache.org/jira/browse/MYFACES-4637. I'm not too sure how much I can help out with Records since they are a Java 14+ feature, and faces-4.0 is built with Java 11. The problem is within our Json encoding logic. We check object type to encode it properly, but since it's a Record, nothing matches. It's ultimately treated as a bean, and the handing is therefore incorrect -- hence empty json data is returned. The only workaround I can provide is to call toString() on the collection, which works in my testing. Nevertheless, I'll collaborate with the open source community via the JIRA above. Perhaps there may be something else we can do here. I'm curious how the Apache Arvo classes are generated? I would expect classes to work? Can you provide an example? |
Providing minimal example on github: https://github.com/hrsto/jakarta-faces-bug-report Run it locally via liberty maven plugin Avro class generated with avro plugin: Open page |
Thanks for providing an app. I see that in the avro case, the JSON encoding fails on the line
The issue is that getElementType throws an exception:
MyFaces' JSON.java class looks at all the properties of the object it's encoding and tries to call all the read methods. As for why the Schema class is getting encoded -- Your object SomeSample contains the mention getSchema, so the JSON encoder tries to encode the Schema$RecordSchema, too. That's where it encounters the getElementType method. I'm not sure what exactly could be done here in MyFaces. You might need to use toString here as well. SomeSample#toString returns: |
Jakarta Faces 4.1 (EE11) will be built with Java 17 -- this means we can support Java Records. We only have the 4.1-RC1 out right now, and we haven't added record encoding just yet. I'll aim to have this in 4.1.0-RC2 (or whichever release is next). When we beta faces, you you be able to send records. |
I've fixed the record encoding in MyFaces 4.1. It will be in the next release ( RC3 currently). As for avro encoding, I'm not sure what I can do as I mentioned before. We could have a exception for Avro code, but that means we'd need to use it as a dependency, and that's not ideal. I'll keep this issue open until we pull the record into Liberty. Note that the |
Describe the bug
jakarta.faces.push.PushContext#send(Object)
fails in these cases:send(Object)
Steps to Reproduce
Follow javadoc of
jakarta.faces.push.Push
to setup basic code.<f:websocket channel="myStream" onmessage="myStreamListener" />
Expected behavior
Should receive a properly serialized object. Should support java record classes.
Diagnostic information:
$WLP_OUTPUT_DIR/messages.log
: no error messages, or any message at all is being outputted at the time of sending websocket messages.Additional context
Above issues disappear as soon as i start using POJOs.
The text was updated successfully, but these errors were encountered: