{"action":"created","issue":{"url":"https://api.github.com/repos/openhab/openhab/issues/3223","labels_url":"https://api.github.com/repos/openhab/openhab/issues/3223/labels{/name}","comments_url":"https://api.github.com/repos/openhab/openhab/issues/3223/comments","events_url":"https://api.github.com/repos/openhab/openhab/issues/3223/events","html_url":"https://github.com/openhab/openhab/issues/3223","id":109211372,"number":3223,"title":"jsr223 engine throws null pointer exception, breaks system when started at default runlevel within IDE","user":{"login":"berndpfrommer","id":6206826,"avatar_url":"https://avatars.githubusercontent.com/u/6206826?v=3","gravatar_id":"","url":"https://api.github.com/users/berndpfrommer","html_url":"https://github.com/berndpfrommer","followers_url":"https://api.github.com/users/berndpfrommer/followers","following_url":"https://api.github.com/users/berndpfrommer/following{/other_user}","gists_url":"https://api.github.com/users/berndpfrommer/gists{/gist_id}","starred_url":"https://api.github.com/users/berndpfrommer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berndpfrommer/subscriptions","organizations_url":"https://api.github.com/users/berndpfrommer/orgs","repos_url":"https://api.github.com/users/berndpfrommer/repos","events_url":"https://api.github.com/users/berndpfrommer/events{/privacy}","received_events_url":"https://api.github.com/users/berndpfrommer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-10-01T01:23:05Z","updated_at":"2015-10-02T13:06:52Z","closed_at":null,"body":"If the jsr223 engine plugin is started at the default runlevel, and a script is present (e.g.  foo.js  is in the scripts directory),  the  NPE below is thrown, and the system goes into an unusable state (items are no longer found etc).\r\n\r\nThe reason seems to be a circular reference, the details of which I don't comprehend. Just fixing the NPE (for instance by deferring setting \"active\" to true at a later time) does not do the trick (I tried), the system will still be in a broken state as far as item discovery is concerned.\r\n\r\nThe workaround is to bump the runlevel to 5 (with all the other bundles starting at runlevel 4). Somehow that does the trick. Another (hardly practical) workaround is to only copy the scripts into place after startup.\r\n\r\n<pre>\r\njava.lang.NullPointerException\r\n\tat org.openhab.core.jsr223.internal.engine.Jsr223Engine.runStartupRules(Jsr223Engine.java:201)\r\n\tat org.openhab.core.jsr223.internal.engine.Jsr223Engine.allItemsChanged(Jsr223Engine.java:116)\r\n\tat org.openhab.core.internal.items.ItemRegistryImpl.allItemsChanged(ItemRegistryImpl.java:201)\r\n\tat org.openhab.core.internal.items.ItemRegistryImpl.addItemProvider(ItemRegistryImpl.java:138)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:497)\r\n\tat org.eclipse.equinox.internal.ds.model.ComponentReference.bind(ComponentReference.java:376)\r\n\tat org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bindReference(ServiceComponentProp.java:444)\r\n\tat org.eclipse.equinox.internal.ds.InstanceProcess.dynamicBind(InstanceProcess.java:416)\r\n\tat org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:334)\r\n\tat org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)\r\n\tat org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)\r\n\tat org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)\r\n\tat org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)\r\n\tat org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)\r\n\tat org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)\r\n\tat org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)\r\n\tat org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)\r\n\tat org.eclipse.equinox.internal.ds.InstanceProcess.registerService(InstanceProcess.java:536)\r\n\tat org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:260)\r\n\tat org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)\r\n\tat org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)\r\n\tat org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)\r\n\tat org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)\r\n\tat org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)\r\n\tat org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)\r\n\tat org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)\r\n\tat org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)\r\n\tat org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)\r\n\tat org.eclipse.equinox.internal.ds.InstanceProcess.registerService(InstanceProcess.java:536)\r\n\tat org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:260)\r\n\tat org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)\r\n\tat org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)\r\n\tat org.eclipse.equinox.internal.ds.SCRManager.startedBundle2(SCRManager.java:657)\r\n\tat org.eclipse.equinox.internal.ds.SCRManager.startedBundle(SCRManager.java:578)\r\n\tat org.eclipse.equinox.internal.ds.SCRManager.bundleChanged(SCRManager.java:237)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:847)\r\n\tat org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)\r\n\tat org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)\r\n\tat org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1568)\r\n\tat org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1504)\r\n\tat org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1499)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:356)\r\n\tat org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)\r\n\tat org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)\r\n\tat org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)\r\n\tat org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)\r\n\tat org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)\r\n\tat org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:452)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)\r\n\tat org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)\r\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:357)\r\n\tat org.openhab.model.script.internal.ScriptActivator.start(ScriptActivator.java:47)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)\r\n\tat java.security.AccessController.doPrivileged(Native Method)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)\r\n\tat org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)\r\n\tat org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)\r\n\tat org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)\r\n\tat org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)\r\n\tat org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)\r\n\tat org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)\r\n\tat org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:452)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)\r\n\tat org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)\r\n\tat org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)\r\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:357)\r\n\tat org.openhab.core.jsr223.internal.engine.scriptmanager.Script.initializeGeneralGlobals(Script.java:222)\r\n\tat org.openhab.core.jsr223.internal.engine.scriptmanager.Script.initializeSciptGlobals(Script.java:99)\r\n\tat org.openhab.core.jsr223.internal.engine.scriptmanager.Script.loadScript(Script.java:87)\r\n\tat org.openhab.core.jsr223.internal.engine.scriptmanager.Script.<init>(Script.java:76)\r\n\tat org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptManager.loadScript(ScriptManager.java:90)\r\n\tat org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptManager.loadScripts(ScriptManager.java:79)\r\n\tat org.openhab.core.jsr223.internal.engine.scriptmanager.ScriptManager.<init>(ScriptManager.java:68)\r\n\tat org.openhab.core.jsr223.internal.engine.Jsr223Engine.activate(Jsr223Engine.java:71)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:497)\r\n\tat org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)\r\n\tat org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)\r\n\tat org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)\r\n\tat org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)\r\n\tat org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)\r\n\tat org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)\r\n\tat org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)\r\n\tat org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)\r\n\tat org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)\r\n\tat org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n</pre>"},"comment":{"url":"https://api.github.com/repos/openhab/openhab/issues/comments/145015509","html_url":"https://github.com/openhab/openhab/issues/3223#issuecomment-145015509","issue_url":"https://api.github.com/repos/openhab/openhab/issues/3223","id":145015509,"user":{"login":"lewie","id":5707426,"avatar_url":"https://avatars.githubusercontent.com/u/5707426?v=3","gravatar_id":"","url":"https://api.github.com/users/lewie","html_url":"https://github.com/lewie","followers_url":"https://api.github.com/users/lewie/followers","following_url":"https://api.github.com/users/lewie/following{/other_user}","gists_url":"https://api.github.com/users/lewie/gists{/gist_id}","starred_url":"https://api.github.com/users/lewie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lewie/subscriptions","organizations_url":"https://api.github.com/users/lewie/orgs","repos_url":"https://api.github.com/users/lewie/repos","events_url":"https://api.github.com/users/lewie/events{/privacy}","received_events_url":"https://api.github.com/users/lewie/received_events","type":"User","site_admin":false},"created_at":"2015-10-02T13:06:52Z","updated_at":"2015-10-02T13:06:52Z","body":"HA, I had a look in my OH Eclipse Environment and in openHAB Runtime.launch jsr223 starts on start-level 5.\r\nHad a look in git History, since 4 month Merschjohann has commited jsr223 with start-level 5.\r\n\r\n\r\nYour failure mode can not work, because jsr223 must have access to some classes of persistence Services!\r\nMy Startorder with start-level 5:\r\n````\r\n14:39:46.127 [DEBUG] [.p.i.PersistenceModelActivator:23   ] - Registered 'persistence' configuration parser\r\n14:39:46.378 [DEBUG] [.i.internal.ItemModelActivator:24   ] - Registered 'item' configuration parser\r\n14:39:46.975 [DEBUG] [.o.m.s.i.SitemapModelActivator:23   ] - Registered 'sitemap' configuration parser\r\n14:39:57.010 [DEBUG] [.r.internal.RuleModelActivator:42   ] - Registered 'rules' configuration parser\r\n14:40:00.303 [DEBUG] [j.internal.Jsr223CoreActivator:33   ] - Registered 'jsr223' scripting-engine\r\n````\r\n\r\nAll is well now? :-)\r\n\r\nRgds\r\nHelmut\r\n"}}