-->

Wrong WebTarget implementation SseEventSource

2019-07-17 07:50发布

问题:

I have implemented a method to receive live notification from OpenHab in my application through SSE events. Previously I used glassfish server to deploy my application. But I needed to switch to Payara and now the sse connection won't be established. I am getting following error:

Argument fish.payara.requesttracing.jaxrs.client.decorators.JaxrsWebTargetDecorator@45>314ad8 is not a valid JerseyWebTarget instance. SseEventSource does not support other WebTarget implementations.

When switching back to glassfish server the code runs perfectly. And I can establish a sse connection.

WebTarget wt =  requestHelper.buildTarget(
                "/events",
                new String[0],
                new Object[0],
                new String[]{"topics"},
                new String[]{String.format("smarthome/%s/%s/%s", "items", itemName, "statechanged")});

        eventSource = SseEventSource
                .target(wt)
                .build();

This is my Webtarget building. In the .build It checks if webTarget is instance of JerseyWebTarget, but in my case it is JaxrsWebTargetDecorator and I can't explain why. Does anyone know where the issue is?