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

Can't change the root path via config admin #75

Closed lwrobel1 closed 9 years ago

lwrobel1 commented 9 years ago

Hi Holger,

I'm having a problem with changing /services context path via osgi config admin. I'm trying to change it from within activator of my service bundle:

public void start(BundleContext bundleContext) throws Exception {
    helloSrvReg = bundleContext.registerService(HelloFacade.class, new HelloFacadeImpl(), null);

    final ServiceReference svcRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
    final ConfigurationAdmin cfgAdmin = bundleContext.getService(svcRef);
    final Configuration cfg = cfgAdmin.getConfiguration("com.eclipsesource.jaxrs.connector");
    Dictionary<String, Object> props = cfg.getProperties();
    if (null == props) {
        props = new Hashtable<String, Object>();
    }
    props.put("root", "/foo");
    cfg.update(props);

    Activator.context = bundleContext;
}

The problem is that properties returned by cfg.getProperties() is always null and adding a new instance with "root" property (as shown above) has no effect. The org.eclipse.equinox.cm bundle is present and active (started with a start level one point lower than the connector). The issue seems to be the same as described in the blog comment at http://eclipsesource.com/blogs/2014/05/26/osgi-jax-rs-connector-4-0-released/comment-page-1/#comment-105024. I realize it may be something with my implementation and no necessarily a project issue but I couldn't find a solution and the blog post seemed too old to respond to.

Cheers, Lukas

lwrobel1 commented 9 years ago

A short update. While investigating the issue I found this explanation: http://stackoverflow.com/questions/25225824/could-not-run-configuration-admin-on-eclipse Even though I use equinox implementation rather than felix, the solution still worked.

final Configuration cfg = cfgAdmin.getConfiguration("com.eclipsesource.jaxrs.connector", null);

The properties are still null when read but once instantiated and updated, new settings are respected and context path updates properly. Seems unrelated to the connector but perhaps it's worth to put an example somewhere in docs/faq for future reference.

Cheers, Lukas

iberrada commented 9 years ago

Hi Lukas,

I have the same problem and I'v done the same thing than you even if I'm using felix rathen than eclipse But I still have a 404 error Things that seems strange to me is that I can see on felix's web console that the configuration is available

PID = com.eclipsesource.jaxrs.connector BundleLocation = file:/opt/felix-framework-4.4.1/bundle/publisher-3.3.jar root = /foo service.pid = com.eclipsesource.jaxrs.connector

I send the HTTP request with curl curl -v -X GET http://localhost:8080/foo/path/to/my/ressource and i'm getting an 404 error Don't you mind post your full example even with the web service class ?

regards