osgi-jax-rs-connector icon indicating copy to clipboard operation
osgi-jax-rs-connector copied to clipboard

I think I'm being an idiot

Open dementiacs opened this issue 7 years ago • 0 comments

Wanted to try out your JAX-RS connector for OSGi but I doesn't do anything. I'm pretty new to OSGi so I'm thinking I must be doing something wrong. I'm using Felix OSGi 5.6.2 and bndtools 3.3.

Here is what I've done...

  1. Added the com.eclipsesource.jaxrs.jersey-all (2.22.2) bundle to my project.
  2. Created a simple service as below
import javax.ws.rs.GET;
import javax.ws.rs.Path;

import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.log.LogService;

@Path("/hello")
@Component(immediate=true, service = Example.class)
public class Example
{
    @Reference(policy = ReferencePolicy.STATIC)
    private LogService log;
    
    @Activate
    void activate(ComponentContext argComponentContext, BundleContext argBundleContext) throws Exception
    {
        this.log.log(LogService.LOG_INFO, "Activated!!!");
    }
    
    @GET
    public String helloWorld()
    {
        return "Hello World";
    }

}
  1. Started it all up with the following bundles included and my service is successfully activated

    org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',
    org.apache.felix.configadmin;version='[1.8.8,1.8.9)',
    org.apache.felix.eventadmin;version='[1.4.6,1.4.7)',
    org.apache.felix.http.jetty;version='[3.4.2,3.4.3)',
    org.apache.felix.metatype;version='[1.0.10,1.0.11)',
    aQute.xray.plugin;version='[1.7.0,1.7.1)',
    org.apache.felix.webconsole;version='[4.2.0,4.2.1)',
    org.apache.felix.scr;version='[2.0.2,2.0.3)',
    org.apache.felix.log;version='[1.0.1,1.0.2)',
    com.eclipsesource.jaxrs.jersey-min;version='[2.22.2,2.22.3)'

Problem is, nothing else happens. None of your services appear to start (according to the Felix web console) and as a result my attempts at poking http://localhost:8080/services/hello fail with

HTTP ERROR: 404

Problem accessing /services/hello. Reason:

Not Found

Question is: What am I forgetting/not understanding here?

dementiacs avatar Mar 24 '17 15:03 dementiacs