You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by simplemind <pa...@gmail.com> on 2011/05/17 11:51:01 UTC

crazy infinite bundle activation

Because I couldn't get war to work I was trying to get the HttpService and
add my servlet to it directly.  It has 2 problems.  1. it goes into a
strange binding/unbinding loop.  2. only some of the expected output is
printed to the output.  Why does it loop?  Why isn't there more output? 
Code is at bottom of message.

When I drop the Hello.jar file into karaf/deploy/ the log file says:

pServiceFactoryImpl   33 | 65 - org.ops4j.pax.web.pax-web-runtime - 1.0.3 |
Binding bundle: [ebento.rest.helloworld [83]] to http service
02:29:32,521 | INFO  | raf-2.2.1/deploy | HttpServiceFactoryImpl           |
.internal.HttpServiceFactoryImpl   40 | 65 -
org.ops4j.pax.web.pax-web-runtime - 1.0.3 | Unbinding bundle:
[ebento.rest.helloworld [83]]
pServiceFactoryImpl   33 | 65 - org.ops4j.pax.web.pax-web-runtime - 1.0.3 |
Binding bundle: [ebento.rest.helloworld [83]] to http service
02:29:32,521 | INFO  | raf-2.2.1/deploy | HttpServiceFactoryImpl           |
.internal.HttpServiceFactoryImpl   40 | 65 -
org.ops4j.pax.web.pax-web-runtime - 1.0.3 | Unbinding bundle:
[ebento.rest.helloworld [83]]
<repeat forever>

And the karaf.out says:

Activating resteasy servlet bundle.
Activating resteasy servlet bundle.
Activating resteasy servlet bundle.
Activating resteasy servlet bundle.
Activating resteasy servlet bundle.
Activating resteasy servlet bundle.
<repeat forever>

Here is the code:

public class Activator implements BundleActivator {

    ResteasyServlet s = null;

    public void start(BundleContext context) throws Exception {

        System.err.println("Activating resteasy servlet bundle.");
  try {
        String httpServiceName = HttpService.class.getName();
        ServiceReference httpRef =
context.getServiceReference(httpServiceName);
        if (httpRef != null) {
            HttpService httpSvc = (HttpService)context.getService(httpRef);
            if (httpSvc != null) {
                s = new ResteasyServlet();
                httpSvc.registerServlet("/hello", s, null, null);
                System.err.println("Servlet registered.");
                if (s.getServletContext() != null) {
                    System.err.println("Servlet context not null");
                }
                s.addResource(new HelloResource());
            } else {
                System.err.println("HttpService is null.");
            }
        } else {
            System.err.println("HttpService reference is null.");
        }
  } catch (Exception e) {
    e.printStackTrace(System.err);
  }

    }

    public void stop(BundleContext context) throws Exception {
        System.err.println("Stopping resteasy servlet bundle.");
        s.removeResource(HelloResource.class);
    }
}


--
View this message in context: http://karaf.922171.n3.nabble.com/crazy-infinite-bundle-activation-tp2951853p2951853.html
Sent from the Karaf - User mailing list archive at Nabble.com.