{"action":"created","issue":{"url":"https://api.github.com/repos/eclipse/jetty.project/issues/213","repository_url":"https://api.github.com/repos/eclipse/jetty.project","labels_url":"https://api.github.com/repos/eclipse/jetty.project/issues/213/labels{/name}","comments_url":"https://api.github.com/repos/eclipse/jetty.project/issues/213/comments","events_url":"https://api.github.com/repos/eclipse/jetty.project/issues/213/events","html_url":"https://github.com/eclipse/jetty.project/issues/213","id":134127383,"number":213,"title":"jetty.osgi.boot requires Server services registered before ContextHandler services","user":{"login":"jmcc0nn3ll","id":273327,"avatar_url":"https://avatars.githubusercontent.com/u/273327?v=3","gravatar_id":"","url":"https://api.github.com/users/jmcc0nn3ll","html_url":"https://github.com/jmcc0nn3ll","followers_url":"https://api.github.com/users/jmcc0nn3ll/followers","following_url":"https://api.github.com/users/jmcc0nn3ll/following{/other_user}","gists_url":"https://api.github.com/users/jmcc0nn3ll/gists{/gist_id}","starred_url":"https://api.github.com/users/jmcc0nn3ll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmcc0nn3ll/subscriptions","organizations_url":"https://api.github.com/users/jmcc0nn3ll/orgs","repos_url":"https://api.github.com/users/jmcc0nn3ll/repos","events_url":"https://api.github.com/users/jmcc0nn3ll/events{/privacy}","received_events_url":"https://api.github.com/users/jmcc0nn3ll/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eclipse/jetty.project/labels/Bug","name":"Bug","color":"eb6420"}],"state":"closed","locked":false,"assignee":{"login":"janbartel","id":342406,"avatar_url":"https://avatars.githubusercontent.com/u/342406?v=3","gravatar_id":"","url":"https://api.github.com/users/janbartel","html_url":"https://github.com/janbartel","followers_url":"https://api.github.com/users/janbartel/followers","following_url":"https://api.github.com/users/janbartel/following{/other_user}","gists_url":"https://api.github.com/users/janbartel/gists{/gist_id}","starred_url":"https://api.github.com/users/janbartel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janbartel/subscriptions","organizations_url":"https://api.github.com/users/janbartel/orgs","repos_url":"https://api.github.com/users/janbartel/repos","events_url":"https://api.github.com/users/janbartel/events{/privacy}","received_events_url":"https://api.github.com/users/janbartel/received_events","type":"User","site_admin":false},"assignees":[{"login":"janbartel","id":342406,"avatar_url":"https://avatars.githubusercontent.com/u/342406?v=3","gravatar_id":"","url":"https://api.github.com/users/janbartel","html_url":"https://github.com/janbartel","followers_url":"https://api.github.com/users/janbartel/followers","following_url":"https://api.github.com/users/janbartel/following{/other_user}","gists_url":"https://api.github.com/users/janbartel/gists{/gist_id}","starred_url":"https://api.github.com/users/janbartel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janbartel/subscriptions","organizations_url":"https://api.github.com/users/janbartel/orgs","repos_url":"https://api.github.com/users/janbartel/repos","events_url":"https://api.github.com/users/janbartel/events{/privacy}","received_events_url":"https://api.github.com/users/janbartel/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2016-02-16T23:35:09Z","updated_at":"2016-07-28T01:23:02Z","closed_at":"2016-07-28T01:23:02Z","body":"migrated from Bugzilla [#470116](https://bugs.eclipse.org/bugs/show_bug.cgi?id=470116)\nstatus ASSIGNED severity *normal* in component *osgi* for *9.3.x*\nReported in version *9.2.9* on platform *Other*\nAssigned to: Jan Bartel\n\nOn 2015-06-12 17:51:00 -0400, Magnus Jungsbluth wrote:\n\n> I really like the service based ContextHandler approach to deploying web apps with jetty.osgi.boot. I stumbled on some oddity and found that in ServiceWatcher#addService if no Server is registered with a matching name no deployment will ever happen. If the Server was registered later the ContextHandler should still be deployed.\n> \n> The really bad corollary of this is that ports are open before content is deployed. This means that for fractions of a second 404 status codes can be received which is especially bad for rest style services booting up under high load.\n> \n> As a possible workaround we can register a root handler that returns 5XX status codes if no child handler handles the request\n\nOn 2015-06-19 02:07:47 -0400, Jan Bartel wrote:\n\n> Magnus,\n> \n> Hmmm .... tricky ...\n> \n> As regards the startup scenario where the server starts before any contexts are deployed to it, certainly the simplest thing to do is to modify the jetty.xml file that configures the default server instance and have the DefaultHandler return a page of your choice.  \n> \n> There are a couple of ways that I can think of to implement preventing a server from opening its connectors before any contexts are deployed to it but they're mostly ugly solutions. Nor do they prevent the need for the DefaultHandler as the handler-of-last-resort and an informative error page. Consider these scenarios:\n> \n> +  there are contexts deployed to the server instance on startup, but none of them are started. In non-osgi jetty the connectors would still open, but the DefaultHandler will handle requests.\n> \n> + after the server instance has started, all of the deployed contexts have been stopped, thus requests will fall through to the DefaultHandler.\n> \n> Having the server look for bundles  & services to deploy after it has started is also problematic ... I think the solution would entail each of the 4 flavours of deployer (BundleContextProvider, BundleWebAppProvider, ServiceContextProvider, ServiceWebAppProvider) each iterating over all the bundles or services at startup time to see which could be deployed. In the case of the services, its not too inefficient, as they can be filtered by the class type (ContextHandler or WebAppContext). But in the case of the Bundle providers, they have no choice but to each iterate over all of the Bundles installed in the system, which could be very very many.\n> \n> Jan\n\nOn 2015-06-25 06:37:42 -0400, Magnus Jungsbluth wrote:\n\n> I neither use a jetty.xml not the DefaultHandler, since I configure the Server directly in code. \n> \n> Maybe let's just split the two concerns (correctness w.r.t start order and open ports).\n> \n> Concerning correctness (In OSGi it should not matter when a service is registered) and looking for existing services bundles I would propose the following (I am not sitting in front of the Jetty code atm so I might be off at some point):\n> - You are already using ServiceTrackerS as far as I remember so you already have all existing services right there and locally cached (no need to query again). The culprit is that they are opened when the Activator starts and events are only processed if the Server service already exist\n> - If you open the required ServiceTrackerS at the time of Server discovery you get both for free (events are fired for existing ContextHandler/WebApp services and events for services that come later). The only really difference would by that a more specific OSGi filter would be required (i.e. (&(objectClass=ContextHandler)(managedServer=mySuperServer)) )\n> - I am not sure about the case where no \"managedServer\" property is used (i.e. default). Maybe for this case you still need to open a ServiceTracker with a filter like (!(managedServer=*))\n> - I would not handle the BundleTracking part specifically and leave it as is since as far as I remember the osgi.boot bundle registers approbate ContextHandler WebApp... services respectively so this would be solved automatically if the above changes are applied\n> \n> I wouldn't expect the inner code to change much but changes around the Activator and the methods where ServerS added/removed events are processed. \n> \n> Does this sound like a viable approach?\n\nOn 2015-08-25 15:21:49 -0400, Wei Yan wrote:\n\n> Have the same issue here, server won't deploy the context handler created before server starting.\n\n"},"comment":{"url":"https://api.github.com/repos/eclipse/jetty.project/issues/comments/235770710","html_url":"https://github.com/eclipse/jetty.project/issues/213#issuecomment-235770710","issue_url":"https://api.github.com/repos/eclipse/jetty.project/issues/213","id":235770710,"user":{"login":"janbartel","id":342406,"avatar_url":"https://avatars.githubusercontent.com/u/342406?v=3","gravatar_id":"","url":"https://api.github.com/users/janbartel","html_url":"https://github.com/janbartel","followers_url":"https://api.github.com/users/janbartel/followers","following_url":"https://api.github.com/users/janbartel/following{/other_user}","gists_url":"https://api.github.com/users/janbartel/gists{/gist_id}","starred_url":"https://api.github.com/users/janbartel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janbartel/subscriptions","organizations_url":"https://api.github.com/users/janbartel/orgs","repos_url":"https://api.github.com/users/janbartel/repos","events_url":"https://api.github.com/users/janbartel/events{/privacy}","received_events_url":"https://api.github.com/users/janbartel/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T01:23:02Z","updated_at":"2016-07-28T01:23:02Z","body":"Fixed for jetty-9.3.11 and above.\r\n\r\nAs a result of the fix, it will no longer be possible for jetty to generate an error message for a context or webapp deployed as either a bundle or service for which a corresponding jetty server instance cannot be found. Note that it is still valid not to provide the name of a target server instance on the webapp/context bundle or service properties - this will be deployed to the default server instance. This caveat only applies if you deploy to a server instance named \"fooServer\" and no such server instance exists."}}
{"actor":{"display_login":"janbartel"}}