users@tyrus.java.net

RE: Tyrus Websocket Client Endpoints and OSGI bundle

From: Beaulieu, Paul <Paul.Beaulieu_at_parexel.com>
Date: Wed, 22 Apr 2015 15:20:43 +0000

Hi Michał,

Thanks for your help, this got me over the hurdle with Felix. It works great. It would be great to understand better the interactions for the bundle classloaders and the issues I was running into earlier, and why I could not use the dependencies I was using, but that is for a later time.

Again thanks and best regards,

Paul

From: Michał Ćmil [mailto:cmilmichal_at_gmail.com]
Sent: Monday, April 20, 2015 10:05 AM
To: users_at_tyrus.java.net
Subject: Re: Tyrus Websocket Client Endpoints and OSGI bundle

Hi Paul,

I'm using Tyrus in Equinox. My gradle dependency signature is:
compile 'org.glassfish.tyrus.bundles:tyrus-standalone-client:1.8.2'

It works without any problems - what artifact and version do you use?

Best Regards,
Michal

On Mon, Apr 20, 2015 at 3:27 PM Pavel Bucek <pavel.bucek_at_oracle.com<mailto:pavel.bucek_at_oracle.com>> wrote:

Hi Paul,

can you please share reproducible testcase? (preferably: minimal, github hosted, maven project).

We do test this only on Glassfish, which is OSGi container, but from what I recall, there are some internal inconsistencies when compared to plan Felix / other containers.

Thanks,
Pavel

On 20/04/15 15:08, Beaulieu, Paul wrote:
Hi,

I have an OSGI bundle in which I am trying to start a Websocket client. The problem is that the org.glassfish.tyrus.container.grizzly.client.GrizzlyClientContainer cannot be found. The issue is that the bundle classloader for the tyrus-core cannot find this class. If everything is placed into a normal jar file, then it all works. The problem is with the classloaders being able to find the tyrus classes that are required.

The code snippet that I have is below

              ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build();
              ClientManager client = ClientManager.createClient();

              client.connectToServer(this, cec, new URI(endpoint));

The problem is at the ClientManager.createClient() where the GrizzlyClientContainer cannot be found with the following exception:
java.lang.ClassNotFoundException: org.glassfish.tyrus.container.grizzly.client.GrizzlyClientContainer not found by org.glassfish.tyrus.core [30]

Is there anything special that needs to be done in order for this to work in an OSGI bundle?

I am using an apache Felix framework for loading the OSGI bundles.

Thanks for any help you can provide.

Paul Beaulieu