j4nSolo
j4nSolo

Reputation: 402

BundleContext's getServiceReference of an HttpService returns null

I'm creating a web service with Java but already at the very start am having problems. In the line of code below where I ask the context to get me the ServiceReference, it returns null.

import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;

public class MapService {
    public void addUrl(BundleContext context) {
        try {
            HttpService http;
            ServiceReference ref = context.getServiceReference("org.osgi.service.http.HttpService");
            http = (HttpService)context.getService(ref);
            HttpContext ctx = http.createDefaultHttpContext();
            ...

Now, what I could find out debugging is that my context has no servicesInUse but I'm not sure if that is indicative of something.

enter image description here

I played a bit too with the bundles' start levels with no success, this is my current configuration:

enter image description here

Upvotes: 0

Views: 28

Answers (0)

Related Questions