2 Replies Latest reply on Dec 18, 2013 3:48 PM by Savvas Andreas Moysidis

    Inheritance support in websocket encoder

    Savvas Andreas Moysidis Newbie



      I am testing the latest WildFly build (wildfly-8.0.0.Beta2-SNAPSHOT) and have come across the following issue:


      I have two classes (POJOs): ClassA and ClassB with ClassB being a subclass of ClassA so ClassB extends ClassA.


      Now, I specify an encoder in my @ServerEndpoint like:

      @ServerEndpoint(......., encoders = { ClassAEncoder.class } ,....)


      The encoder ClassAEncoder implements Encoder.Text<ClassA> {....}


      but, when I try to send an object like:



      I am getting the following exception:

      "Caused by: javax.websocket.EncodeException: No suitable encoder found"


      If I change my Encoder to "implements Encoder.Text<ClassB> {....}" everything is working fine.

      Does this mean that inheritance doesn't work with Encoders and that an encoder has to be defined for each subclass? I went through the jsr spec but it doesn't seem to say much about encoders in general, does it? Just a brief description at the @ServerEndpoint section.


      Any thoughts?