Strange auto uninstall for marketplace kar file (pythonscripting)

I observed a strange behavior with my pythonscripting binding. Maybe someone has an idea? Maybe @Nadahar

If I install the included one, everything works.

If I install the marketplace version via WebUI or via “addons” folder, it works for several seconds and is then uninstalled automatically again. This happend in my test setup and for someone else too. But it works in my production setup without any problems.

First I increased the log level

openhab> log:set TRACE org.openhab.core.addon.marketplace
openhab> log:set TRACE org.osgi.framework

after the installation my features looks like

openhab> feature:list | grep ython
openhab-automation-pythonscripting                    │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ Python Scripting
org.openhab.automation.pythonscripting                │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ openHAB Add-ons :: Bundles :: Automation :: Pytho
openhab-automation-jythonscripting                    │ 5.0.0            │          │ Uninstalled │ openhab-addons-5.0.0                                  │ Jython Scripting
openhab-automation-pythonscripting                    │ 5.0.0            │          │ Uninstalled │ openhab-addons-5.0.0                                  │ Python Scripting

the related bundle state is

openhab> bundle:list | grep ython                                                                                                                                                                                                                                                                                                                                        
469 │ Active │  78 │ 24.2.1                │ GraalVM :: Python :: Language
470 │ Active │  78 │ 24.2.1                │ GraalVM :: Python :: Resources
484 │ Active │  80 │ 5.0.0.202507241323    │ openHAB Add-ons :: Bundles :: Automation :: Python Scripting
487 │ Active │  80 │ 0                     │ wrap_file__openhab_userdata_tmp_kar_org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT_org_lastnpe_eea_eea-all_2.4.0_eea-all-2.4.0.jar

the related logs of the installation are

2025-07-25 09:30:04.735 [DEBUG] [ity.CommunityBlockLibaryAddonHandler] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler(1625)] : dm $000 tracking 3 SingleStatic removed {org.openhab.core.ui.components.UIComponentRegistryFactory}={service.id=2194, service.bundleid=223, service.scope=bundle, osgi.ds.satisfying.condition.target=(osgi.condition.id=true), $000.target=(component.factory=org.openhab.core.ui.component.provider.factory), component.name=org.openhab.core.ui.internal.components.UIComponentRegistryFactoryImpl, component.id=1725} (enter)
2025-07-25 09:30:04.735 [DEBUG] [ity.CommunityBlockLibaryAddonHandler] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler(1625)] : Querying state active
2025-07-25 09:30:04.735 [DEBUG] [ity.CommunityBlockLibaryAddonHandler] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler(1625)] : Deactivating component
2025-07-25 09:30:04.735 [DEBUG] [ity.CommunityBlockLibaryAddonHandler] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler(1625)] : registration change queue [unregistered]
2025-07-25 09:30:04.735 [DEBUG] [ity.CommunityMarketplaceAddonService] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityMarketplaceAddonService(1627)] : dm AddonHandler tracking 12 MultipleDynamic removed {org.openhab.core.addon.marketplace.MarketplaceAddonHandler}={service.id=2195, service.bundleid=157, service.scope=bundle, osgi.ds.satisfying.condition.target=(osgi.condition.id=true), component.name=org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler, component.id=1625} (enter)
..
..
..

due to the maximum character limit the whole install log can be found here

after a while (between some seconds and 2 minutes) the following logs occurs

2025-07-25 09:31:07.331 [DEBUG] [ity.CommunityBlockLibaryAddonHandler] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler(1747)] : dm $000 tracking 3 SingleStatic removed {org.openhab.core.ui.components.UIComponentRegistryFactory}={service.id=2339, service.bundleid=223, service.scope=bundle, osgi.ds.satisfying.condition.target=(osgi.condition.id=true), $000.target=(component.factory=org.openhab.core.ui.component.provider.factory), component.name=org.openhab.core.ui.internal.components.UIComponentRegistryFactoryImpl, component.id=1847} (enter)
2025-07-25 09:31:07.332 [DEBUG] [ity.CommunityBlockLibaryAddonHandler] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler(1747)] : Querying state active
2025-07-25 09:31:07.332 [DEBUG] [ity.CommunityBlockLibaryAddonHandler] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler(1747)] : Deactivating component
2025-07-25 09:31:07.332 [DEBUG] [ity.CommunityBlockLibaryAddonHandler] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler(1747)] : registration change queue [unregistered]
2025-07-25 09:31:07.332 [DEBUG] [ity.CommunityMarketplaceAddonService] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityMarketplaceAddonService(1749)] : dm AddonHandler tracking 12 MultipleDynamic removed {org.openhab.core.addon.marketplace.MarketplaceAddonHandler}={service.id=2340, service.bundleid=157, service.scope=bundle, osgi.ds.satisfying.condition.target=(osgi.condition.id=true), component.name=org.openhab.core.addon.marketplace.internal.community.CommunityBlockLibaryAddonHandler, component.id=1747} (enter)
2025-07-25 09:31:07.332 [DEBUG] [ity.CommunityMarketplaceAddonService] - bundle org.openhab.core.addon.marketplace:5.0.0 (157)[org.openhab.core.addon.marketplace.internal.community.CommunityMarketplaceAddonService(1749)] : getting unbind: removeAddonHandler
..
..
..

due to the maximum character limit the whole uninstall log can be found here

the related feature state is then

openhab> feature:list | grep ython                                                                                                                                                                                                                                                                                                                                       
openhab-automation-pythonscripting                    │ 5.0.0.SNAPSHOT   │          │ Uninstalled │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ Python Scripting
org.openhab.automation.pythonscripting                │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ openHAB Add-ons :: Bundles :: Automation :: Pytho

and the related bundle state is

openhab> bundle:list | grep ython
466 │ Active │  80 │ 0                     │ wrap_file__openhab_userdata_tmp_kar_org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT_org_lastnpe_eea_eea-all_2.4.0_eea-all-2.4.0.jar

— UPDATE related to my production system —

This error does not happen if I download the kar file. Put it to the addons folder. And this is important, I configure the Addons via the conf/services/addons.cfg

If I put automation = jsscripting,pythonscripting there, everything works. Not auto uninstallation.

This is installing the default jsscripting which comes with openhab and in addition, it is installing pythonscripting from the kar file inside the addons folder.

This works without jsscripting too. I just added it to show that they are not influencing each other and can work together.

Important is also that the original Python Scripting binding is not active before. Otherwise you have 2 running Add-ons at the same time and you have to manually stop/clean it via the console.

In my marketplace page I descibed the only working way to install my Add-on and keep it running. But this is the worst userexperience ever and I guess, with that way, I won’t convince new users to test it.

If you use addons.cfg to install your add-ons, that takes precedence over anything you do through the REST API/UI/Karaf Console. So the behavior you describe is expected for “normal” distro add-ons. OH periodically checks addons.cfg and if the current set of addons does not match what addons.cfg says it should be, it will install and remove those outliers until it reaches the set listed in addons.cfg.

This is really the only way you can manage uninstalling addons when using addons.cfg which is why it is implemented this way.

However, it’s only supposed to do this on a per entry basis. For example, if you only use the binding property in the file and the rest are commented out, you can install BasicUI (for example) through the API and all will work as expected. Your UI addons will be managed and your bindings will be controlled by addons.cfg.

There should be a way to list marketplace addons in addons.cfg ,but I do not know how to do it. I’ve been on a managed config for many years now. I think it might be something like marketplace:164947 where the 164947 is the posting number for the marketplace forum post. I’m not in a place where I can test that right now though.

The overall precedence is:

  • addons folder
  • addons.cfg
  • managed

Anything you do in the addons folder is going to stick. Anything you do (or don’t do) in addons.cfg is going to override the managed config. So if you have the official python add-on installed using addons.cfg and then try to install the marketplace add-on through the UI, the marketplace add-on will eventually be removed and the official one restored.

I’m not 100% certain that is what’s happening here, but it sure sounds like it. However, there could be something else going on here if the marketplace files are not named properly. See Problem with binding from marketplace being installed and subsequently uninstalled on OH start-up - #5 by andirs.

You’ll always have to uninstall the official python add-on first. If you are using an unmanaged config that means remove it from the addons.cfg before installing the marketplace add-on. I don’t know for certain though if marketplace add-ons and official addons are handled differently meaning you can keep the other entries in addons.cfg and use the APIs for marketplace addons.

Thanks for this explanation. But I still believe there is something wired.

I tested the following scenarios (everytime with a new openhab container and a cleaned userdata folder)

  • Scenario 1-3 are single pythonscripting (default & marketplace) installations and works perfectly :white_check_mark:
  • Scenario 4 installs jsscripting and pythonscripting (default), needs a restart, are explainable and acceptable :white_check_mark:
  • Scenario 5 & 6 installs jsscripting and pythonscripting (marketplace) and uninstalls pythonscripting automatically :warning:
  • Scenario 7 installs jsscripting and pythonscripting (marketplace), needs a restart, are explainable and acceptable :white_check_mark:

all of that is reproducible

Scenarios

1. Single default Python Scripting via webUI (:white_check_mark: Successful)

  • There is nothing configured in addoncs.cfg and nothing inside the addons folder
  • Installing of the default Python Scripting via WebUI
  • Everything was installed and the python script files are loaded and executed successful
      openhab> bundle:list | grep "Python Scripting"                                                                                                                                                                                                                                                                                         
      285 │ Active │  80 │ 5.0.0                 │ openHAB Add-ons :: Bundles :: Automation :: Python Scripting
      openhab> feature:list | grep "Python Scripting"                                                                                                                                                                                                                                                                                                                     
      openhab-automation-pythonscripting                    │ 5.0.0            │ x        │ Started     │ openhab-addons-5.0.0     │ Python Scripting
    
  • Everything works perfect for at least 5 minutes. Then I jumped over to the next scenario.

2. Single marketplace Python Scripting Next via webUI (:white_check_mark: Successful)

  • There is nothing configured in addoncs.cfg and nothing inside the addons folder
  • Installing of the Python Scripting Next via WebUI
  • Everything was installed and the python script files are loaded and executed successful
      openhab> bundle:list | grep "ython"                                                                                                                                                                                                                                                                                                           
      282 │ Active │  80 │ 5.0.0.202507241323    │ openHAB Add-ons :: Bundles :: Automation :: Python Scripting
      285 │ Active │  80 │ 0                     │ wrap_file__openhab_userdata_tmp_kar_org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT_org_lastnpe_eea_eea-all_2.4.0_eea-all-2.4.0.jar
      openhab> feature:list | grep "ython"                                                                                                                                                                                                                                                                                                              
      openhab-automation-pythonscripting                    │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ Python Scripting
      org.openhab.automation.pythonscripting                │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ openHAB Add-ons :: Bundles :: Automation :: Pytho
      openhab-automation-pythonscripting                    │ 5.0.0            │          │ Uninstalled │ openhab-addons-5.0.0                                  │ Python Scripting
    
  • There was a error message like “[t.core.internal.addons.AddonResource] - Exception while installing add-on: Configuration Admin service has been unregistered”, but I guess it is unrelated
  • Everything works perfect for at least 5 minutes. Then I jumped over to the next scenario.

3. Single marketplace Python Scripting Next via addons folder (:white_check_mark: Successful)

  • There is nothing configured in addoncs.cfg
  • Putting of the Python Scripting Next Snapshot kar file into the addons folder
  • Everything was installed and the python script files are loaded and executed successful
      openhab> bundle:list | grep ython
      281 │ Active   │  80 │ 5.0.0.202507241323    │ openHAB Add-ons :: Bundles :: Automation :: Python Scripting
      285 │ Active   │  80 │ 0                     │ wrap_file__openhab_userdata_tmp_kar_org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT_org_lastnpe_eea_eea-all_2.4.0_eea-all-2.4.0.jar
      openhab> feature:list | grep ython                                                                                                                                                                                                                                                                                                                
      openhab-automation-pythonscripting                    │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ Python Scripting
      org.openhab.automation.pythonscripting                │ 5.0.0.SNAPSHOT   │          │ Uninstalled │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ openHAB Add-ons :: Bundles :: Automation :: Pytho
      openhab-automation-pythonscripting                    │ 5.0.0            │          │ Uninstalled │ openhab-addons-5.0.0                                  │ Python Scripting
    
  • Everything works perfect for at least 5 minutes. Then I jumped over to the next scenario.

4. Default JSScripting via webUI and default Python Scripting via webUI (:warning: ERROR & after restart :white_check_mark: Successful)

  • There is nothing configured in addoncs.cfg and nothing inside the addons folder
  • Installing of the default JSScripting followed by default Python Scripting via WebUI
  • JSScripting works
  • Python Scripting throws an exception
    “java.lang.NullPointerException: Cannot invoke “org.graalvm.polyglot.Language.getName()” because “language” is null”
    • this could happen, because this just means that the graal dependency is not loaded in the correct order
      • I checked that all bundles (including the graal bundles are active)
      openhab> bundle:list | grep "Python Scripting"                                                                                                                                                                                                                                                                                         
      285 │ Active │  80 │ 5.0.0                 │ openHAB Add-ons :: Bundles :: Automation :: Python Scripting
      openhab> feature:list | grep "Python Scripting"                                                                                                                                                                                                                                                                                                                     
      openhab-automation-pythonscripting                    │ 5.0.0            │ x        │ Started     │ openhab-addons-5.0.0     │ Python Scripting
    
  • If I installed first Python Scripting and then JSScripting, JSScripting was throwing an exception
    “java.lang.IllegalArgumentException: Could not find option with name js.commonjs-require.”
  • JSScripting & Python Scripting was working properly after a openhab restart without any exception for at least 5 minutes. Then I jumped over to the next scenario.

:information_source: This is acceptable, because it is explainable

5. Default JSScripting via webUI and marketplace Python Scripting Next via webUI (:warning: ERROR)

  • There is nothing configured in addoncs.cfg and nothing inside the addons folder
  • Installing of the default JSScripting followed by marketplace Python Scripting Next via WebUI
  • JSScripting works
  • Python Scripting throws an exception
    “java.lang.IllegalStateException: Graal python language not available”
    • this could happen, because this just means that the graal dependency is not loaded in the correct order
      • I checked that all bundles (including the graal bundles are active)
    • but this can normaly be solved with an openhab restart
      openhab> bundle:list | grep ython                                                                                                                                                                                                                                                                                                                                        
      285 │ Active │  80 │ 5.0.0.202507241323    │ openHAB Add-ons :: Bundles :: Automation :: Python Scripting
      288 │ Active │  80 │ 0                     │ wrap_file__openhab_userdata_tmp_kar_org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT_org_lastnpe_eea_eea-all_2.4.0_eea-all-2.4.0.jar
      openhab> feature:list | grep ython                                                                                                                                                                                                                                                                                                                                  
      openhab-automation-pythonscripting                    │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ Python Scripting
      org.openhab.automation.pythonscripting                │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ openHAB Add-ons :: Bundles :: Automation :: Pytho
      openhab-automation-pythonscripting                    │ 5.0.0            │          │ Uninstalled │ openhab-addons-5.0.0                                  │ Python Scripting
    
  • Python Scripting Next was uninstalled automatically after ~30 seconds
      openhab> bundle:list | grep ython                                                                                                                                                                                                                                                                                                                                  
      288 │ Active │  80 │ 0                     │ wrap_file__openhab_userdata_tmp_kar_org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT_org_lastnpe_eea_eea-all_2.4.0_eea-all-2.4.0.jar
      openhab> feature:list | grep ython                                                                                                                                                                                                                                                                                                                                  
      openhab-automation-pythonscripting                    │ 5.0.0.SNAPSHOT   │          │ Uninstalled │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ Python Scripting
      org.openhab.automation.pythonscripting                │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ openHAB Add-ons :: Bundles :: Automation :: Pytho
      openhab-automation-pythonscripting                    │ 5.0.0            │          │ Uninstalled │ openhab-addons-5.0.0                                  │ Python Scripting
    

6. Default JSScripting via webUI and marketplace Python Scripting Next via addons folder (:warning: ERROR)

  • There is nothing configured in addoncs.cfg
  • Installing of the default JSScripting followed by marketplace Python Scripting Next via addons folder
  • JSScripting works
  • Python Scripting throws an exception
    “java.lang.IllegalStateException: Graal python language not available”
      openhab> bundle:list | grep ython                                                                                                                                                                                                                                                                                                                                        
      285 │ Active │  80 │ 5.0.0.202507241323    │ openHAB Add-ons :: Bundles :: Automation :: Python Scripting
      288 │ Active │  80 │ 0                     │ wrap_file__openhab_userdata_tmp_kar_org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT_org_lastnpe_eea_eea-all_2.4.0_eea-all-2.4.0.jar
      openhab> feature:list | grep ython                                                                                                                                                                                                                                                                                                                                  
      openhab-automation-pythonscripting                    │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ Python Scripting
      org.openhab.automation.pythonscripting                │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ openHAB Add-ons :: Bundles :: Automation :: Pytho
      openhab-automation-pythonscripting                    │ 5.0.0            │          │ Uninstalled │ openhab-addons-5.0.0                                  │ Python Scripting
    
  • Python Scripting Next was uninstalled automatically after ~30 seconds
      openhab> bundle:list | grep ython                                                                                                                                                                                                                                                                                                                                  
      288 │ Active │  80 │ 0                     │ wrap_file__openhab_userdata_tmp_kar_org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT_org_lastnpe_eea_eea-all_2.4.0_eea-all-2.4.0.jar
      openhab> feature:list | grep ython                                                                                                                                                                                                                                                                                                                                  
      openhab-automation-pythonscripting                    │ 5.0.0.SNAPSHOT   │          │ Uninstalled │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ Python Scripting
      org.openhab.automation.pythonscripting                │ 5.0.0.SNAPSHOT   │ x        │ Started     │ org.openhab.automation.pythonscripting-5.0.0-SNAPSHOT │ openHAB Add-ons :: Bundles :: Automation :: Pytho
      openhab-automation-pythonscripting                    │ 5.0.0            │          │ Uninstalled │ openhab-addons-5.0.0                                  │ Python Scripting
    
  • Behavior is similar to scenario 5

7. Default JSScripting via addons.cfg and marketplace Python Scripting Next via addons folder and enabled via addons.cfg too (:warning: ERROR & after restart :white_check_mark: Successful)

  • Installing of the default JSScripting via addons.cfg followed by marketplace Python Scripting via addons folder and addons.cfg too
  • JSScripting works
  • Python Scripting throws an exception
  • The rest is similar to scenario 4
  • This means after a restart everything works

:information_source: This is acceptable too, because it is explainable

Conclusion

  • Every Add-on alone works perfectly. Independently if they are installed via webUI or addons folder and if they are the default ones or not.

  • The problems begins if jsscriptiung and pythonscripting comes together

    • :warning: & :white_check_mark: If both Add-ons are the default ones and installed via webUI it works perfectly after a restart (the explanation is the dependency loading order)
    • :warning: If Python Scripting is the marketplace version and installed via webUI it never works. It will always be uninstalled
    • :warning: If Python Scripting is the marketplace version and installed via addons folder it never works too. It will always be uninstalled
    • :warning: & :white_check_mark: If Python Scripting is the marketplace version and installed via addons folder and enabled via addons.cfg it works after a restart too. (the explanation is the dependency loading order)

If both are the default ones, after a restart is everything is fine. This is ok, because it is explainable.

:information_source: If Pythonscripting is the marketplace one, both Add-ons have to be activated in addons.cfg. There is no other way to get this combination working

Is 5 and 6 perhaps related to the issue that was fixed that prevented JS Scripting and Python Scripting being installed at the same time? I know that problem was fixed but perhaps this behavior is another similar edge case.

5 and 6 definitely are not related to the order of precedence I discussed above.

this is not related anymore. It was fixed before the official 5.0.0 release

And in scenario 4 & 7 both binding are working together.

scenario 4 is where both are the default ones
scenario 7 is where pythonscripting is the marketplace ones

this is what it makes so strange

Pythonscripting marketplace (webUI and addons folder) alone works always

Pythonscripting marketplace together with JSScripting have to be deployed inside addons folder and activated inside addons.cfg. Otherwise it will never work.

I’m aware of it. Also an empty “automation=” entry will uninstall all of your automation addons from webui. So I’m not mixing it. Either I try to install all via webUI or all via addons.cfg.

maybe an additional explanation

  1. If one automation Add-on is installed via webUI, and the other one is installed via the addons folder, the AddonService is assuming that all is coming from webUI and this is maybe the reason why the addons folder version is uninstalled. But this speaks agains

You can solve this by activate both (webUI based and addon folder based) in addons.cfg.

  1. But this still does not explain why default JSScripting and marketplace PythonScripting can’t coexists if both are installed via webUI. They can only coexists, if JSScripting is installed via webUI, Python Scripting via addons folder and both are activated via addons.cfg

Maybe I will debug it sometime. I hope someone can give me a hint, which class could be the right place to start. This package handles only the marketplace. But I think the decision when to uninstall is made somewhere else.

Here are some findings.

Reason:
The root source is that during the first installation, if jsscripting is available too, the graalpy engine is not available quickly enough. The reason is that the osgi dependencies are defined, but not 100% reliable that the dependencies are really up and running. This is why the binding crashes during service registration.

Scenario 1-3 Add-on install without jsscripting (Works)
If the Add-on is installed alone, the osgi related problem does not occur. This is why the bundle installs perfectly.

Scenario 4 The Add-on is installed after JSScripting (Works acceptable)
With this installation method, it crashes during the service registration, but it is not uninstalled, because it is a provided (default) Add-on and not a kar file. After restart, all graal dependenvies are resolved properly, the service registration fished and jsscripting and pythonscripting are working fine

Scenario 5 & 6 The Add-on is installed after JSScripting (Does not work)
With this installation methods, it crashes too during the service registration, and it is uninstalled, because both scenarios are based on kar files. It looks like that kar files are cleaned if a service registration is not successful. So also a restart will not help, as it is already cleaned.

Scenario 7 The Add-on is installed together with JSScripting (Works acceptable)
With this installation method, it crashes too and it is a kar file. But it is not uninstalled, because additionally it is configured/fixed in addons.cfg. That’s the reason why it is not cleaned and after a restart it is still installed and finishes the service registration.

@ccutrer I rember that you mention, during our “OSGI-ified Graal dependencies” work, the possibility that feature dependencies are not 100% reliable in some situations, to be up and running. Do you have an idea how to be 100% reliable resolving the dependencies?

@florian-h05 fyi

— UPDATE —

I thing it has nothing to do that the dependencies are not quickly enough up and running. My guess is now that the available languages are cached somehow in graalvm. And if the jsscripting is initialized, the available languages are initialized too.
That means, if I install pythonscripting after, the GraalPy dependency is resolved, but not added as an available language, because it is cached. But if I restart openhab, the cache is reinitialized with both languages.
I verified this behavior with a very ugly Thread which was checking, the available languages. And the second language never occurs (but GraalPy Add-on was active), until I restarted openhab.

I think this is not really solvable from our side. That means from my perspective the only doable solution is to not clean failed kar files. This would allow to continue after a restart.

1 Like

Ooh, interesting. And yes, you got it exactly. Polyglot keeps an internal cache of languages that it loads as a static initializer. It has no way to reload this. This is why we set start levels to ensure the language providers start before Polyglot. But if you already have Graal running due to JSScripting installed, and then install an addon that needs Python, the Python bundles will start, then the addon (Pythonscripting) bundle will start, and ask Polyglot to create a Python engine, and Polyglot will say “no idea what you’re talking about, sorry,” and thus the python scripting bundle will fail to start. Which I guess you’re seeing that the feature installer is backing out the entire feature installation when one of its bundles fails to start?

In an ideal world, we could get the Polyglot bundle to restart when the Python bundle is installed. But I don’t know how to make that happen. Maybe some kludgey workaround when you create an engine if you get an error that Python can’t be found, then go find the Polyglot bundle and restart it once, just to see if it will work? I dunno if that would work though - does OSGi serialize all bundle starts, so it would essentially deadlock if you try to restart a bundle in the course of your bundle starting up?

What if add-ons had a special “Polyglot” property that if true, the Polyglot bundle would be found and stopped before installation of the add-on was attempted. If we’re really lucky, the feature installer would then attempt to start the Polyglot bundle as a part of the installation process, the static cache would be generated correctly, and all would be friends..?