Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolver errors during bundle add-on installation #4224

Merged
merged 2 commits into from
May 11, 2024

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented May 11, 2024

Fixes #4222

@lolodomo @holgerfriedrich @jimtng Can you confirm this also fixes the issues on your systems? My Win11/Parallels now works fine.

@J-N-K J-N-K added bug An unexpected problem or unintended behavior of the Core critical labels May 11, 2024
@J-N-K J-N-K requested a review from a team as a code owner May 11, 2024 12:34
Signed-off-by: Jan N. Klug <[email protected]>
@jimtng
Copy link
Contributor

jimtng commented May 11, 2024

I rebuilt openhab-core (mvn -T 4 -D skipTests=true clean install) then I copied ~/.m2/repository/org/openhab/core/bundles/ into my openhab installation runtime/system/org/openhab/core/bundles/ and tried starting it up, but the error is still there.

What did I miss?

@J-N-K
Copy link
Member Author

J-N-K commented May 11, 2024

I think the important file is runtime/system/org/openhab/distro/distro/4.2.0-SNAPSHOT/distro-4.2.0-SNAPSHOT-features.xml. If you edit that file (and remove the conditional sections (like in this PR) it should work. Make sure to clean cache and tmp before starting openHAB.

@jimtng
Copy link
Contributor

jimtng commented May 11, 2024

Thanks! That did the trick

I saw a few errors like these:

00:14:30.315 [ERROR] [.core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-core-config-discovery-addon-mdns, openhab-automation-pidcontroller, openhab-core-config-discovery-addon-upnp, openhab-automation-jrubyscripting, openhab-core-config-discovery-addon-usb, openhab-core-config-discovery-addon-ip': Error restarting bundles:
        Exception in org.glassfish.hk2.osgiresourcelocator.Activator.start() of bundle org.glassfish.hk2.osgi-resource-locator.
00:15:21.503 [ERROR] [.core.karaf.internal.FeatureInstaller] - Failed to refresh bundles after processing config update
org.apache.karaf.features.internal.util.MultiException: Error restarting bundles:
        Exception in org.glassfish.hk2.osgiresourcelocator.Activator.start() of bundle org.glassfish.hk2.osgi-resource-locator.
        at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1049) ~[?:?]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069) ~[?:?]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
        at java.lang.Thread.run(Thread.java:840) [?:?]
        Suppressed: org.osgi.framework.BundleException: Exception in org.glassfish.hk2.osgiresourcelocator.Activator.start() of bundle org.glassfish.hk2.osgi-resource-locator.
                at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:839) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:767) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.container.Module.doStart(Module.java:605) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.container.Module.start(Module.java:468) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:445) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:464) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:165) ~[?:?]
                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1160) ~[?:?]
                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1041) ~[?:?]
                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069) ~[?:?]
                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004) ~[?:?]
                at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
                at java.lang.Thread.run(Thread.java:840) [?:?]
        Caused by: java.lang.IllegalStateException: Already initialzed with [org.glassfish.hk2.osgiresourcelocator.ServiceLoaderImpl@222b7a14]
                at org.glassfish.hk2.osgiresourcelocator.ServiceLoader.initialize(ServiceLoader.java:43) ~[?:?]
                at org.glassfish.hk2.osgiresourcelocator.Activator.start(Activator.java:32) ~[?:?]
                at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1) ~[org.eclipse.osgi-3.18.0.jar:?]
                at java.security.AccessController.doPrivileged(AccessController.java:569) ~[?:?]
                at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:810) ~[org.eclipse.osgi-3.18.0.jar:?]
                ... 16 more

However, the bundles got installed despite the errors.

e.g. I tried adding astro, and this happened, even though astro binding got installed

00:19:22.255 [ERROR] [.core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-binding-astro': Error restarting bundles:
        Exception in org.glassfish.hk2.osgiresourcelocator.Activator.start() of bundle org.glassfish.hk2.osgi-resource-locator.
00:19:22.869 [ERROR] [.core.karaf.internal.FeatureInstaller] - Failed to refresh bundles after processing config update
org.apache.karaf.features.internal.util.MultiException: Error restarting bundles:
        Exception in org.glassfish.hk2.osgiresourcelocator.Activator.start() of bundle org.glassfish.hk2.osgi-resource-locator.
        at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1049) ~[?:?]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069) ~[?:?]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
        at java.lang.Thread.run(Thread.java:840) [?:?]
        Suppressed: org.osgi.framework.BundleException: Exception in org.glassfish.hk2.osgiresourcelocator.Activator.start() of bundle org.glassfish.hk2.osgi-resource-locator.
                at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:839) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:767) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.container.Module.doStart(Module.java:605) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.container.Module.start(Module.java:468) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:445) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:464) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:165) ~[?:?]
                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1160) ~[?:?]
                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1041) ~[?:?]
                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069) ~[?:?]
                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004) ~[?:?]
                at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
                at java.lang.Thread.run(Thread.java:840) [?:?]
        Caused by: java.lang.IllegalStateException: Already initialzed with [org.glassfish.hk2.osgiresourcelocator.ServiceLoaderImpl@222b7a14]
                at org.glassfish.hk2.osgiresourcelocator.ServiceLoader.initialize(ServiceLoader.java:43) ~[?:?]
                at org.glassfish.hk2.osgiresourcelocator.Activator.start(Activator.java:32) ~[?:?]
                at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818) ~[org.eclipse.osgi-3.18.0.jar:?]
                at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1) ~[org.eclipse.osgi-3.18.0.jar:?]
                at java.security.AccessController.doPrivileged(AccessController.java:569) ~[?:?]
                at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:810) ~[org.eclipse.osgi-3.18.0.jar:?]
                ... 16 more

@jimtng
Copy link
Contributor

jimtng commented May 11, 2024

I tried the following:

  • Install a clean snapshot build 4070
  • Edit ./runtime/system/org/openhab/distro/distro/4.2.0-SNAPSHOT/distro-4.2.0-SNAPSHOT-features.xml and remove the <conditional> tags just like in this PR
  • Start openhab
  • No errors

It appears that the changes in this PR to FeatureInstaller is not necessary, and it actually caused a new error. Only the change in the xml is required.

@J-N-K
Copy link
Member Author

J-N-K commented May 11, 2024

Correct, it's not necessary, but it should make the whole process a bit more safe (in case of the unlikely case that a subsequent config change happens before the refresh finished).

@holgerfriedrich
Copy link
Member

Confirmed to work with a clean build on Windows. Thanks a lot, @J-N-K! 🎉

@lolodomo
Copy link
Contributor

Big thanks to @J-N-K for fixing this critical issue. I have not tested myself but I would have done the same as @jimtng .

@kaikreuzer @wborn : please merge ASAP.

@holgerfriedrich holgerfriedrich merged commit ec76747 into openhab:main May 11, 2024
5 checks passed
@holgerfriedrich
Copy link
Member

I wanted to check for implications of activating the finders on other OS as well, e.g. see Windows:

255 │ Active   │  80 │ 4.2.0.202405111317    │ openHAB Core :: Bundles :: Configuration USB-Serial Discovery for Linux using sysfs scanning
257 │ Active   │  80 │ 4.2.0.202405111321    │ openHAB Core :: Bundles :: Configuration USB-Serial Discovery for Windows

I did not see a problem on Windows and as this is a blocking issue, lets go for the merge first.

@J-N-K J-N-K deleted the fix-bundle-installation branch May 11, 2024 17:36
@holgerfriedrich
Copy link
Member

@openhab/core-maintainers can anyone please trigger a snapshot build?

@J-N-K
Copy link
Member Author

J-N-K commented May 11, 2024

Done

@lolodomo
Copy link
Contributor

I wanted to check for implications of activating the finders on other OS as well, e.g. see Windows:

255 │ Active   │  80 │ 4.2.0.202405111317    │ openHAB Core :: Bundles :: Configuration USB-Serial Discovery for Linux using sysfs scanning
257 │ Active   │  80 │ 4.2.0.202405111321    │ openHAB Core :: Bundles :: Configuration USB-Serial Discovery for Windows

I did not see a problem on Windows and as this is a blocking issue, lets go for the merge first.

I agree that a solution has to be found. I have now a bundle for Windows on RPI.

256 x Active x  80 x 4.2.0.202405111809    x openHAB Core :: Bundles :: USB Suggested Add-on Finder
257 x Active x  80 x 4.2.0.202405111808    x openHAB Core :: Bundles :: Configuration USB-Serial Discovery
258 x Active x  80 x 4.2.0.202405111809    x openHAB Core :: Bundles :: Configuration USB-Serial Discovery for Linux using sysfs scanning
259 x Active x  80 x 4.2.0.202405111809    x openHAB Core :: Bundles :: Configuration USB-Serial Discovery using ser2net mDNS scanning
260 x Active x  80 x 4.2.0.202405111809    x openHAB Core :: Bundles :: Configuration USB-Serial Discovery for Windows

@J-N-K
Copy link
Member Author

J-N-K commented May 12, 2024

That's more cosmetic, correct? It does not result in any malfunction, as far as I know.

@holgerfriedrich
Copy link
Member

holgerfriedrich commented May 12, 2024

Neither a malfunction nor a log message seems to be caused by this. IMHO we can leave it as it is for now.

@lolodomo
Copy link
Contributor

Yes, it seems to be without any impact.

@holgerfriedrich holgerfriedrich added this to the 4.2 milestone May 15, 2024
@lolodomo
Copy link
Contributor

Someone in the community forum is reporting this error while he uses openhabian :

[ERROR] [y.internal.WindowsUsbSerialDiscovery] - bundle org.openhab.core.config.discovery.usbserial.windowsregistry:4.2.0.M3 (320)[org.openhab.core.config.discovery.usbserial.windowsregistry.internal.WindowsUsbSerialDiscovery(389)] : The deactivate method has thrown an exception

@lolodomo
Copy link
Contributor

lolodomo commented May 20, 2024

The error occurs when stopping openHAB.


2024-05-20 09:31:16.303 [ERROR] [y.internal.WindowsUsbSerialDiscovery] - bundle org.openhab.core.config.discovery.usbserial.windowsregistry:4.2.0.M3 (258)[org.openhab.core.config.discovery.usbserial.windowsregistry.internal.WindowsUsbSerialDiscovery(321)] : The deactivate method has thrown an exception
java.lang.UnsupportedOperationException: null
        at java.util.ImmutableCollections.uoe(Unknown Source) ~[?:?]
        at java.util.ImmutableCollections$AbstractImmutableCollection.clear(Unknown Source) ~[?:?]
        at org.openhab.core.config.discovery.usbserial.windowsregistry.internal.WindowsUsbSerialDiscovery.deactivate(WindowsUsbSerialDiscovery.java:97) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:245) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:687) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:531) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:317) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:307) ~[?:?]
        at org.apache.felix.scr.impl.manager.SingleComponentManager.disposeImplementationObject(SingleComponentManager.java:421) ~[?:?]
        at org.apache.felix.scr.impl.manager.SingleComponentManager.deleteComponent(SingleComponentManager.java:165) ~[?:?]

@mherwege
Copy link
Contributor

The error occurs when stopping openHAB.

Fixed with #4235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core critical
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Snapshot 4069: failed to install bundles at startup
5 participants