hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

Unable to get monitoring feature to work #143

Open webtrekk-kane opened 8 years ago

webtrekk-kane commented 8 years ago

In a Karaf 3.x environment with Jolokia feature installed, I want to enable the Jersey MBeans feature to fetch statistics for all my resources.

First, I tried with just exposing an ApplicationConfiguration service using the following configuration:

jersey.config.server.monitoring.enabled = true
jersey.config.server.monitoring.statistics.enabled = true
jersey.config.server.monitoring.statistics.mbeans.enabled = true

...according to https://jersey.java.net/documentation/latest/monitoring_tracing.html.

This does not work at all and I figured out, that the default configuration explicitly disables the auto-discoverable features, so I added a jersey.config.server.disableAutoDiscovery = false to the configuration without success.

In the next step I explicitly registered the MonitoringFeature myself inside an Activator, with the result that I then get the MBeans registered and exposed, but they don't seem to get actually used or updated - which may relate to a race-condition when binding actual resources to features at the time that Jersey configures the resource instance.

hstaudacher commented 8 years ago

Registering the feature yourself is the right apporach. To configure your application please register com.eclipsesource.jaxrs.publisher.ApplicationConfiguration as a service and provide the properties you want to use.

webtrekk-kane commented 8 years ago

OK, that is what I am doing right now, but my ApplicationConfiguration is registered via Declarative Services, while the MonitoringFeature is registered with a standard OSGi Activator. In addition, both of these are registered by a Bundle different from the actual JAX-RS resource(s). So, could this be a timing problem for service registration?