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

Using jackson-module-jakarta-xmlbind-annotations 2.15.2 fails in OSGi Environment with JAXB 4 #219

Closed
col-panic opened this issue Sep 27, 2023 · 10 comments

Comments

@col-panic
Copy link

col-panic commented Sep 27, 2023

Using the bundle Jackson Module Jakarta Xmlbind Annotations » 2.15.2 by integrating it via the target like

grafik

fails with

  -> Bundle-SymbolicName: org.glassfish.jersey.media.jersey-media-json-jackson; bundle-version="3.1.3"
       org.glassfish.jersey.media.jersey-media-json-jackson [40]
         Unresolved requirement: Import-Package: com.fasterxml.jackson.module.jaxb; version="[2.14.0,3.0.0)"; resolution:="optional"
         Unresolved requirement: Import-Package: com.fasterxml.jackson.module.jakarta.xmlbind; version="[2.14.0,3.0.0)"
           -> Export-Package: com.fasterxml.jackson.module.jakarta.xmlbind; bundle-symbolic-name="com.fasterxml.jackson.module.jackson-module-jakarta-xmlbind-annotations"; bundle-version="2.15.2"; version="2.15.2"; uses:="com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.databind,com.fasterxml.jackson.databind.cfg,com.fasterxml.jackson.databind.introspect,com.fasterxml.jackson.databind.jsontype,com.fasterxml.jackson.databind.type,com.fasterxml.jackson.databind.util,jakarta.xml.bind.annotation,jakarta.xml.bind.annotation.adapters"
              com.fasterxml.jackson.module.jackson-module-jakarta-xmlbind-annotations [86]
                Unresolved requirement: Import-Package: jakarta.xml.bind; version="[3.0.0,4.0.0)"

I can see that the limitation is also set in the META-INF/MANIFEST.MF in

https://repo1.maven.org/maven2/com/fasterxml/jackson/module/jackson-module-jakarta-xmlbind-annotations/2.15.2/jackson-module-jakarta-xmlbind-annotations-2.15.2.jar

Import-Package: com.fasterxml.jackson.annotation;version="[2.15,3)",co
 m.fasterxml.jackson.core;version="[2.15,3)",com.fasterxml.jackson.cor
 e.util;version="[2.15,3)",com.fasterxml.jackson.databind;version="[2.
 15,3)",com.fasterxml.jackson.databind.cfg;version="[2.15,3)",com.fast
 erxml.jackson.databind.deser.std;version="[2.15,3)",com.fasterxml.jac
 kson.databind.introspect;version="[2.15,3)",com.fasterxml.jackson.dat
 abind.jsonFormatVisitors;version="[2.15,3)",com.fasterxml.jackson.dat
 abind.jsontype;version="[2.15,3)",com.fasterxml.jackson.databind.json
 type.impl;version="[2.15,3)",com.fasterxml.jackson.databind.node;vers
 ion="[2.15,3)",com.fasterxml.jackson.databind.ser.std;version="[2.15,
 3)",com.fasterxml.jackson.databind.type;version="[2.15,3)",com.faster
 xml.jackson.databind.util;version="[2.15,3)",com.fasterxml.jackson.mo
 dule.jakarta.xmlbind.deser;version="[2.15,3)",com.fasterxml.jackson.m
 odule.jakarta.xmlbind.ser;version="[2.15,3)",jakarta.activation;versi
 on="[2.0,3)",jakarta.xml.bind;version="[3.0,4)",jakarta.xml.bind.anno
 tation;version="[3.0,4)",jakarta.xml.bind.annotation.adapters;version
 ="[3.0,4)",javax.activation;resolution:=optional

JAXB is brought in as a dependency by jersey-media-jackson

grafik

What version of jackson-module-jakarta-xmlbind-annotations am I supposed to use here? Is there already a version compatible with jakarta.xml.bind >= 4?

@col-panic
Copy link
Author

grafik

@cowtowncoder
Copy link
Member

Unfortunately I do not know enough about OSGi resolution to know.
The whole transition from old JAXB annotations to Jakarta-binding is a royal shitshow, alas.

If anyone can resolve this and submit a patch, would be happy to merge.

@GedMarc any thoughts? (aside from "OSGi sucks" :) )

@col-panic
Copy link
Author

col-panic commented Sep 30, 2023

I don' know, where the MANIFEST.MF is generated (I think it must be during the process of deploying the artifact to maven), but generally, is there a reason to limit Import-Package: jakarta.xml.bind; version="[3.0.0,4.0.0)" and subpackages to "[3.0.0,4.0.0)"? If not, a simple change to "[3.0.0,5.0.0)" to also include version 4 (as defined for Java EE 10 https://jakarta.ee/specifications/xml-binding/4.0/ ) might already suffice. This patch should be rather trivial!

@cowtowncoder
Copy link
Member

MANIFEST.MF is generated by Maven (OSGi) bundle plugin, based on pom.xml and possible overrides. Dependency from FasterXML/oss-parent project's parent pom (https://github.com/FasterXML/oss-parent/blob/master/pom.xml#L248 ) is:

        <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>

But I am not 100% sure where logic for version range generation resides -- definitions are not included in pom.xml, nor do we use version ranges for Maven dependencies (since they don't really work well with tooling).
So it is unfortunately not just matter of changing explicit Import-Package directive as those are generated by the plug-in (AFAIK).

@col-panic
Copy link
Author

I think it might be defined in here _versionpolicy but I'm struggling
to find the documentation to this property, which is currently set to
<osgi.versionpolicy>${range;[===,=+);${@}}</osgi.versionpolicy>

A wild guess would be to change this to
<osgi.versionpolicy>${range;[===,=+];${@}}</osgi.versionpolicy> then it should at least work with the 4.0.0 version.

But in https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-jakarta-xmlbind-annotations/2.15.2 it is even mentioned to accept jakarta.xml.bind » jakarta.xml.bind-api 4.0.1 so we should give this a more educated approach!

Will try to make a meaning of this property!

@col-panic
Copy link
Author

Seems like a good link https://bnd.bndtools.org/macros/range.html

@col-panic
Copy link
Author

But I am not 100% sure where logic for version range generation resides -- definitions are not included in pom.xml, nor do we use version ranges for Maven dependencies (since they don't really work well with tooling).

Does this mean that you actively disable the _versionpolicy property on build, s.t. its not to be considered?

@cowtowncoder
Copy link
Member

I was only talking about Maven side of things: that is, we would never use version ranges for Maven dependencies.
I did not mean it would not be used for OSGi.

Unfortunately I do not know much about workings of Maven bundle (felix?) plugin, or _versionpolicy to be sure.
But. I think at first it would make sense to try overriding that settings on Jakarta XMLBind Annotations module only, not in parent pom (I think it is defined in a way to be overridable), and if that works, publish as part of 2.16.0-rc1 that I plan on publishing some time this week.
If you could help with this @col-panic that'd be awesome.

col-panic added a commit to col-panic/jackson-modules-base that referenced this issue Oct 2, 2023
@col-panic
Copy link
Author

@cowtowncoder this should do the trick. I've seen this a few times in the Eclipse related plugins,
where they enable a certain range for patch levels to apply. So this should cover all jakarta.xml.bind until 4.0.99,
but still leave it closed for a major version like 4.1 - where API might break.

@cowtowncoder cowtowncoder changed the title Using jackson-module-jakarta-xmlbind-annotations 2.15.2 fails in OSGi Environment with JAXB 4 Using jackson-module-jakarta-xmlbind-annotations 2.15.2 fails in OSGi Environment with JAXB 4 Oct 2, 2023
cowtowncoder added a commit that referenced this issue Oct 2, 2023
…osgi

Fix #219: relax jakarta.xml.bind OSGI version dependency
@cowtowncoder
Copy link
Member

Thank you @col-panic for providing the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants