jersey
  1. jersey
  2. JERSEY-836

"javax.servlet.UnavailableException: com.sun.jersey.api.container.ContainerException: No WebApplication provider is present" in Jersey running on OSGi container(Equinox)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: 1.9.1
    • Fix Version/s: 1.9.1
    • Component/s: osgi
    • Labels:
      None
    • Environment:

      Description

      I've found a problem with the Jersey implementation running on OSGi that's tricky.

      The problem is not always reproducible!

      The problem is that jersey jars(com.sun.jersey.jersey-core_1.9.1.jar, com.sun.jersey.jersey-json_1.9.1.jar, com.sun.jersey.jersey-server_1.9.1.jar) use internally something called JAR Service Provider, also known as the META-INF/services system which is not OSGI friendly or this is the JDK (non OSGI ) way of defining dependencies to services -> http://weblogs.java.net/blog/bondolo/archive/2007/09/jxse_25_whats_c_2.html

      What I think happens:
      Jersey jars depend on these services and we use them indirectly as well. As we do not have explicit dependency(in the form of component.xml or something) that says to OSGI to start us when these services are available we receive exceptions due to not yet powered on services.

      Do you have any ideas,suggestions,comments?

      The full stacktrace:

      HTTP ERROR 503

      Problem accessing /test_url. Reason:

      com.sun.jersey.api.container.ContainerException: No WebApplication provider is present

      Caused by:

      javax.servlet.UnavailableException: com.sun.jersey.api.container.ContainerException: No WebApplication provider is present
      at org.eclipse.jetty.servlet.ServletHolder.makeUnavailable(ServletHolder.java:394)
      at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:439)
      at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:245)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
      at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:694)
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:193)
      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:966)
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:349)
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
      at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:37)
      at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:182)
      at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
      at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:136)
      at org.eclipse.jetty.osgi.boot.OSGiAppProvider.addContext(OSGiAppProvider.java:154)
      at org.eclipse.jetty.osgi.boot.internal.webapp.WebappRegistrationHelper.registerWebapplication(WebappRegistrationHelper.java:522)
      at org.eclipse.jetty.osgi.boot.internal.webapp.WebappRegistrationHelper.registerWebapplication(WebappRegistrationHelper.java:438)
      at org.eclipse.jetty.osgi.boot.internal.webapp.JettyContextHandlerServiceTracker.serviceChanged(JettyContextHandlerServiceTracker.java:189)
      at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:104)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:933)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
      at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:756)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:711)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:206)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:507)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:525)
      at org.eclipse.jetty.osgi.boot.JettyBootstrapActivator.registerWebapplication(JettyBootstrapActivator.java:166)
      at org.eclipse.jetty.osgi.boot.internal.webapp.JettyContextHandlerExtender.register(JettyContextHandlerExtender.java:153)
      at org.eclipse.jetty.osgi.boot.internal.webapp.JettyContextHandlerExtender.bundleChanged(JettyContextHandlerExtender.java:63)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:919)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
      at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)

        Activity

        Hide
        aaronjwhiteside added a comment - - edited

        I too have this same issue. The OSGi examples included with jersey do not work.

        And by examples I mean:

        http://jersey.java.net/nonav/documentation/1.9/user-guide.html#d4e1437
        https://maven.java.net/service/local/artifact/maven/redirect?r=releases&g=com.sun.jersey.samples&a=osgi-http-service&v=1.9&c=project&e=zip

        The same is true of the latest 1.11 versions.

        The WAB examples does work, but I get the same exception when trying to use OSGi's HttpService.

        I am using Glassfish 3.1.1.

        Show
        aaronjwhiteside added a comment - - edited I too have this same issue. The OSGi examples included with jersey do not work. And by examples I mean: http://jersey.java.net/nonav/documentation/1.9/user-guide.html#d4e1437 https://maven.java.net/service/local/artifact/maven/redirect?r=releases&g=com.sun.jersey.samples&a=osgi-http-service&v=1.9&c=project&e=zip The same is true of the latest 1.11 versions. The WAB examples does work, but I get the same exception when trying to use OSGi's HttpService. I am using Glassfish 3.1.1.
        Hide
        Jakub Podlesak added a comment -

        Described behaviour could happen when jersey bundles has not been activated/started before the application itself.
        I.e. the META-INF/services registration mechanism in Jersey 1.9 relies on having the jersey bundle activators invoked.

        The above is a guess only, jersey osgi support is continuously tested on felix platform only.
        You write, the issue is tricky and not always reproducible, but exact steps to reproduce using
        equinox at least sometimes are missing.

        Please add some more specific information on how to reproduce the issue, if you want to re-open this.

        Show
        Jakub Podlesak added a comment - Described behaviour could happen when jersey bundles has not been activated/started before the application itself. I.e. the META-INF/services registration mechanism in Jersey 1.9 relies on having the jersey bundle activators invoked. The above is a guess only, jersey osgi support is continuously tested on felix platform only. You write, the issue is tricky and not always reproducible, but exact steps to reproduce using equinox at least sometimes are missing. Please add some more specific information on how to reproduce the issue, if you want to re-open this.

          People

          • Assignee:
            Jakub Podlesak
            Reporter:
            systemniq
          • Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: