Unable to use migrations.xml in demo app

  • Platform information:
    • Hardware: x86 / 16G RAM / enough disk space
    • OS: Linux 6.1 / Fedora 37
    • Java Runtime Environment: OpenJDK 17
    • openHAB version: 4.0.0-SNAPSHOT, commit 8e60e34cedb357cfe4f2c0f1b160fd4bb20bf0a5 (currently main)
  • Issue of the topic: Not able to implement channel migrations similar to there, getting an NoSuchMethodException by the framework when loading the thing. Just added my binding to pom.xml as proposed in the file itself. A resolve via eclipse inside of app.bndrun runs fine.
  • If logs where generated please post these here using code fences:
10:39:09.153 [ERROR] [core.thing.internal.ThingManagerImpl] - bundle org.openhab.core.thing:4.0.0.202303260304 (161)[org.openhab.core.thing.internal.ThingManagerImpl(224)] : The addThingHandlerFactory method has thrown an exception
java.lang.NoSuchMethodError: 'java.lang.Object javax.xml.bind.ServiceLoaderUtil.lookupUsingOSGiServiceLoader(java.lang.String, java.util.logging.Logger)'
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:413) ~[?:?]
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721) ~[?:?]
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662) ~[?:?]
	at org.openhab.core.thing.internal.update.ThingUpdateInstructionReader.readForFactory(ThingUpdateInstructionReader.java:71) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.addThingHandlerFactory(ThingManagerImpl.java:1140) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	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.BindMethod.invoke(BindMethod.java:42) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:2086) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:2061) ~[?:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:443) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:336) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:304) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1232) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1152) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:959) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:895) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1184) ~[?:?]
	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:116) ~[?:?]
	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:120) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:956) ~[?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) ~[?:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151) ~[?:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:936) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:873) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:141) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:261) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:495) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:929) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:915) ~[?:?]
	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:984) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:752) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:674) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:437) ~[?:?]
	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:671) ~[?:?]
	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:310) ~[?:?]
	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:593) ~[?:?]
	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:74) ~[?:?]
	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:460) ~[?:?]
	at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) ~[?:?]
	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) ~[?:?]
	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) ~[?:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:488) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:1) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450) ~[org.eclipse.osgi-3.17.200.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:944) ~[?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) ~[?:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:229) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:138) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:130) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:217) ~[?:?]
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:499) ~[?:?]
	at org.eclipse.osgi.container.Module.start(Module.java:486) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:445) ~[?:?]
	at aQute.launcher.Launcher.start(Launcher.java:699) ~[?:?]
	at aQute.launcher.Launcher.startBundles(Launcher.java:679) ~[?:?]
	at aQute.launcher.Launcher.activate(Launcher.java:585) ~[?:?]
	at aQute.launcher.Launcher.launch(Launcher.java:404) ~[?:?]
	at aQute.launcher.Launcher.run(Launcher.java:186) ~[?:?]
	at aQute.launcher.Launcher.main(Launcher.java:162) ~[?:?]
	at aQute.launcher.pre.EmbeddedLauncher.executeWithRunPath(EmbeddedLauncher.java:170) ~[biz.aQute.launcher.pre.jar:?]
	at aQute.launcher.pre.EmbeddedLauncher.findAndExecute(EmbeddedLauncher.java:135) ~[biz.aQute.launcher.pre.jar:?]
	at aQute.launcher.pre.EmbeddedLauncher.main(EmbeddedLauncher.java:52) ~[biz.aQute.launcher.pre.jar:?]

The setup is quite fresh (from yesterday), according to the docs. The issue is only happening since a migrations.xml was added to the binding (currently undocumented, but propsed by @J-N-K, issue with links). Is there somethong generally broken?

Probably a JAXB bundles need to be added to the demo app, probably

    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-osgi</artifactId>
      <version>2.3.3</version>
    </dependency>

That did not help (also activated the bundle in app.bndrun), also the Jakarta version from your pull request does not work. Iā€™m not sure if the dependency is the issue as the Stacktrace already includes javax.xml.bind, which is part of that library.

Adding following, iā€™m getting a step further:

  <dependency> <!-- taken from your PR !-->
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <version>2.3.3</version>
    </dependency>
    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-osgi</artifactId>
      <version>2.3.3</version>
    </dependency>

New Stacktrace:

23:29:58.007 [WARN ] [.update.ThingUpdateInstructionReader] - Failed to parse update instructions from 'bundleentry://168.fwk1528195520/OH-INF/update/instructions.xml':
javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:232) ~[?:?]
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:375) ~[?:?]
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:691) ~[?:?]
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:632) ~[?:?]
	at org.openhab.core.thing.internal.update.ThingUpdateInstructionReader.readForFactory(ThingUpdateInstructionReader.java:71) ~[?:?]
[...]
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory
[...]

But the ā€œmissingā€ class is contained in jaxb-osgi and also resolved correctly inside the app.bndrun. The order of ā€œRun Bundlesā€ does not seem to make a difference. I currently donā€™t have an idea what to try next.

EDIT: Added more details

The problem seems to be unresolved. I just added a migration to my binding and the same issue occurs when I try to run it from Eclipse.

Did not try again yet but instead wrote the rest of my changes in VS Code. The setup that way is based on a standard openHAB instance with debugging enabled (which can be any instance reachable in the network) just working around the issue. Using VS Code is not as comfortable as eclipse but it does the job.

same problem here.
In openwebnet binding when running in Eclipse the handler is not loaded with same error:

10:39:09.153 [ERROR] [core.thing.internal.ThingManagerImpl] - bundle org.openhab.core.thing:4.0.0.202303260304 (161)[org.openhab.core.thing.internal.ThingManagerImpl(224)] : The addThingHandlerFactory method has thrown an exception
java.lang.NoSuchMethodError: 'java.lang.Object javax.xml.bind.ServiceLoaderUtil.lookupUsingOSGiServiceLoader(java.lang.String, java.util.logging.Logger)'

this happens since there is an /update dir with some update channel instructions.

I temporarly removed the /update dir and the error disappears.

@J-N-K is there a solution for this or an open issue for this to monitor?

The issue itself is in openhab-distro and has been opened already:

AFAIK J-N-K uses IntelliJ so i donā€™t think he is the right person to ask. I am not sure whom to mention here.

I have not solved it neither on my side. I create the instructions.xml file and neutralize it to ā€œ.xmā€ while working in eclipse.

If you face issues with Eclipse then maybe you need to update bnd files which consist bundles used to spin whole thing?

Renaming the file is also a workaround. I tried fiddling around with dependencies and was able to remove the ClassNotFoundException. But there were further issues i currently donā€™t rememberā€¦ Sure, you have to resolve app.bndrun and BOM if changing dependencies.

As I already said here, I believe the issue is that there are different JAXB bundles in the runtime and probably there is a class-loading issue because of that.

This is still happening on OH 4.1.0-SNAPSHOT.
Any suggestion to solve this? (apart from deleting any update fodler and removing the change from commits)

Yes try this fix:

yes, that solved, thanks!

1 Like