Details
-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
Description
http://java.dzone.com/articles/using-java-websockets-jsr-356
This example of WebSocket de-/encoders won't work in WildFly. I get this exception:
javax.websocket.DeploymentException: UT003029: Could not find message parameter on method public void SomeClass.someMethod(SomeMessageType)
As far as I can tell, this is due to a wrong/different implementation in Undertow. Apparently, other application servers handle these cases differently (though I did not test that!), because the tutorial linked above would not exist otherwise.
The problem is the way of determining the type that a de-/encoder handles. In order to do that, Undertow uses the parameter type of the first parameter of the encode/decode method:
https://github.com/undertow-io/undertow/blob/master/websockets-jsr/src/main/java/io/undertow/websockets/jsr/EncodingFactory.java#L263
That won't work if that parameter is generic, because type erasure will turn it into "Object", so that there are plenty of de-/encoders for "Object" registered in the EncodingFactory, but none for the types I need.
The Tyrus reference implementation on the other hand uses a complicated method to retrieve the value from the generic type parameter:
https://github.com/tyrus-project/tyrus/blob/a43ba3af79208048787f4b1706c94379d3f26955/core/src/main/java/org/glassfish/tyrus/core/AnnotatedEndpoint.java#L355
https://github.com/tyrus-project/tyrus/blob/a43ba3af79208048787f4b1706c94379d3f26955/core/src/main/java/org/glassfish/tyrus/core/ReflectionHelper.java
This issue is similar to UNDERTOW-166.