[jboss-jira] [JBoss JIRA] (DROOLS-2840) Java Controller Websocket API - Unmarshal incorrect type

Tri Doan Quang (JIRA) issues at jboss.org
Mon Aug 6 13:25:00 EDT 2018


Tri Doan Quang created DROOLS-2840:
--------------------------------------

             Summary: Java Controller Websocket API - Unmarshal incorrect type
                 Key: DROOLS-2840
                 URL: https://issues.jboss.org/browse/DROOLS-2840
             Project: Drools
          Issue Type: Bug
          Components: kie server
    Affects Versions: 7.9.0.Final
            Reporter: Tri Doan Quang
            Assignee: Maciej Swiderski


I deployed Kie workbench & Kie server .9.0.Final
And I am going to set up client by using websocket API as provided here:
   https://docs.jboss.org/drools/release/7.9.0.Final/drools-docs/html_single/index.html#_kie_server_controller_client_api

```java
KieServerControllerClient client = KieServerControllerClientFactory.newWebSocketClient(URL_WS,
                USER,
                PASSWORD, new TestEventHandler());

        final ServerTemplateList serverTemplateList = client.listServerTemplates();
        System.out.println(String.format("Found %s server template(s) at controller url: %s",
                    serverTemplateList.getServerTemplates().length,
                    URL));
```
However, I got NPE since `serverTemplateList` is NULL.
I dig to the code and observed:

1. Server responses in JSON format:
    '{
  "type" : "SUCCESS",
  "msg" : "",
  "result" : {
    "server-template-list" : {
      "server-template" : [ {
        "server-id" : "kie-server-v1",
        "server-name" : "kie-server-v1",
        "container-specs" : [ ],
        "server-config" : { },
        "server-instances" : [ {
          "server-instance-id" : "kie-server-v1 at 192.168.1.6:8180",
          "server-name" : "kie-server-v1 at 192.168.1.6:8180",
          "server-template-id" : "kie-server-v1",
          "server-url" : "http://192.168.1.6:8180/kie-server/services/rest/server"
        } ],
        "capabilities" : [ "RULE", "PROCESS", "PLANNING" ]
      } ]
    }
  }
}'

2. But the decoder tries to unmarshall to the target object which is not defined well in JSON. It's defined in JAXB
   org.kie.server.controller.api.model.KieServerControllerServiceResponse
```java
  @XmlAttribute
    private ResponseType type;

    @XmlAttribute
    private String msg;

    @XmlElements({
            //Kie Server Controller model
            @XmlElement(name = "server-template-list", type = ServerTemplateList.class),
            @XmlElement(name = "server-template-details", type = ServerTemplate.class),
            @XmlElement(name = "server-template-key-list", type = ServerTemplateKeyList.class),
            @XmlElement(name = "server-template-key", type = ServerTemplateKey.class),
            @XmlElement(name = "container-spec-list", type = ContainerSpecList.class),
            @XmlElement(name = "container-spec-details", type = ContainerSpec.class),
            @XmlElement(name = "server-instance-key-list", type = ServerInstanceKeyList.class),
            @XmlElement(name = "server-instance-key", type = ServerInstanceKey.class),
            @XmlElement(name = "container-details-list", type = ContainerList.class)
    })
    private T result;
```

Similar issues when I tried to register Event notification from Websocket (given in above link). All values are null.

I am not sure I am missing some configuration. 
Any one help me please? Many Thanks.
   



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list