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

[ephemeris] Upgrade/replace Jollyday #3545

Closed
wants to merge 1 commit into from

Conversation

jlaur
Copy link
Contributor

@jlaur jlaur commented Apr 12, 2023

This is my initial attempt to replace https://github.com/svendiedrichsen/jollyday by https://github.com/focus-shift/jollyday

However, I don't know what I'm doing, and how to test it, so creating this draft in case anyone would be able to share hints.

I was able to compile org.openhab.core.ephemeris-4.0.0-SNAPSHOT.jar and replace this in a development installation:

openhab> bundle:uninstall org.openhab.core.ephemeris

and then dropping the JAR. This results in:

2023-04-12 22:43:58.661 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/openHAB/addons/org.openhab.core.ephemeris-4.0.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.core.ephemeris [257]
  Unresolved requirement: Import-Package: de.focus_shift

	at org.eclipse.osgi.container.Module.start(Module.java:463) ~[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.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) ~[?:?]

which I then tried to solve by also dropping jollyday-jaxb-0.14.0.jar as jollyday-jaxb.jar, but without success.

Resolves #3544 (well, that would be the plan)

Signed-off-by: Jacob Laursen <[email protected]>
@J-N-K
Copy link
Member

J-N-K commented Apr 13, 2023

There seem to be several issues:

  • The bundle is not an OSGi bundle, the MANIFEST.MF is missing the required headers to load the bundle in KARAF. This can be worked around by creating a wrapper bundle in openhab-osgiify.
  • The bundle depends on Jakarta EE10 (JAXB 4.0.0), while we use Jakarta EE8 (JAXB 2.3.11). One of the main differences is that Jakarta EE10 uses a namespace of jakarta.xml.bind, while previous versions use javax.xml.bind. I'm not sure if we can install both at the same time, but if that is not the case, the upgrade is a lot of work because it requires changes to a lot of code in core and probably also in addons. Do we really need the jollyday-jaxb bundle or would jollyday-core be enough?

@jlaur
Copy link
Contributor Author

jlaur commented Apr 13, 2023

Thanks @J-N-K. It seems I'm out of my depth here. It's a bit unfortunate like with #3321 and #3315, since outdated dependencies automatically accumulates technical debt. Can you recommend me something specific to read to learn more about OSGi and managing dependencies (as starting point)? Which tools do you use to manage dependencies and figuring out these things?

@J-N-K
Copy link
Member

J-N-K commented Apr 14, 2023

Here I looked in the POM that is available at maven central: https://central.sonatype.com/artifact/de.focus-shift/jollyday-jaxb/0.14.0.

<dependencies>
    <dependency>
      <groupId>de.focus-shift</groupId>
      <artifactId>jollyday-core</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- JAXB -->
    <dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <version>4.0.0</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <version>4.0.2</version>
      <scope>runtime</scope>
    </dependency>

    <!-- Threeten -->
    <dependency>
      <groupId>org.threeten</groupId>
      <artifactId>threeten-extra</artifactId>
    </dependency>

...

Our dependencies are in the compile-BOM, and there you find

    <!-- JAXB -->
    <dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <version>2.3.3</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <groupId>jakarta.activation</groupId>
          <artifactId>jakarta.activation-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

In this case I already knew the differences, but in general I then take a look at the release notes and see if there is an issue.

Regarding the bundle-type: You can download the .jar from maven central, re-name it to .zip and look at the META-INF/MANIFEST.MF. For the jollyday-jaxbit looks like this:

Manifest-Version: 1.0
Created-By: Maven JAR Plugin 3.3.0
Build-Jdk-Spec: 11

OSGi-bundles look like this:

Manifest-Version: 1.0
Automatic-Module-Name: org.openhab.binding.deconz
Bnd-LastModified: 1680941962420
Bundle-Description: This project contains the official add-ons of open
 HAB
Bundle-Developers: openhab;email="[email protected]";name=openHAB;organ
 ization=openHAB;organizationUrl="https://www.openHAB.org"
Bundle-DocURL: https://github.com/openhab/infrastructure/org.openhab.a
 ddons.reactor/org.openhab.addons.reactor.bundles/org.openhab.binding.
 deconz
Bundle-License: "Eclipse Public License 2.0";link="https://www.eclipse
 .org/legal/epl-2.0/"
Bundle-ManifestVersion: 2
Bundle-Name: openHAB Add-ons :: Bundles :: deCONZ Binding
Bundle-SCM: url="https://github.com/openhab/openhab-addons/org.openhab
 .addons.reactor.bundles/org.openhab.binding.deconz",connection="scm:g
 it:https://github.com/openhab/openhab-addons.git/org.openhab.addons.r
 eactor.bundles/org.openhab.binding.deconz",developer-connection="scm:
 git:https://github.com/openhab/openhab-addons.git/org.openhab.addons.
 reactor.bundles/org.openhab.binding.deconz",tag=HEAD
Bundle-SymbolicName: org.openhab.binding.deconz
Bundle-Vendor: openHAB.org
Bundle-Version: 4.0.0.202304080819
...

If you don't see Bundle-ManifestVersion: 2 then you are in trouble and need to create a wrapper bundle.

@jlaur jlaur closed this Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ephemeris] Upgrade/replace Jollyday
2 participants