eclipse-ee4j / jersey

Eclipse Jersey Project - Read our Wiki:
https://github.com/eclipse-ee4j/jersey/wiki
Other
681 stars 340 forks source link

3.1.7 OSGi bundle issue #5661

Closed paulrutter closed 1 month ago

paulrutter commented 1 month ago

When trying to bundle Jersey 3.1.7 as compile dependency in an OSGi bundle via the maven-bundle-plugin (5.1.9, latest), the following error occurs. This didn’t happen with 3.1.6.

Maven version 3.9.x Command: mvn clean install Java version 21.1 (corretto)

build   24-May-2024 18:40:01    [ERROR] Bundle com.abc:jersey-bundle:bundle:55.0-SNAPSHOT : Classes found in the wrong directory: {META-INF/versions/21/org/glassfish/jersey/innate/VirtualThreadSupport$NonLoomishExecutors.class=org.glassfish.jersey.innate.VirtualThreadSupport$NonLoomishExecutors, META-INF/versions/21/org/glassfish/jersey/innate/virtual/LoomishExecutors.class=org.glassfish.jersey.innate.virtual.LoomishExecutors, META-INF/versions/21/org/glassfish/jersey/innate/VirtualThreadSupport$Java21LoomishExecutors.class=org.glassfish.jersey.innate.VirtualThreadSupport$Java21LoomishExecutors, META-INF/versions/21/org/glassfish/jersey/innate/VirtualThreadSupport.class=org.glassfish.jersey.innate.VirtualThreadSupport}
build   24-May-2024 18:40:01    [ERROR] Error(s) found in bundle configuration

Did anything change in this regard or would this be an issue in the maven bundle plugin from Apache Felix?

Thanks!

paulrutter commented 1 month ago

Maybe this instruction could help, i will try: https://bnd.bndtools.org/instructions/jpms-multi-release.html

paulrutter commented 1 month ago

Probably related to this commit https://github.com/eclipse-ee4j/jersey/pull/5648/files#diff-c5f428df9f7559f2cbd2b51eb8af37214c2ac0dab80414c95d16a7d59b909413

paulrutter commented 1 month ago

There seems to be support for this, so probably not a jersey issue. See https://github.com/bndtools/bnd/issues/2227

I will close it for now and try to fix it with bnd instructions in the maven bundle plugin first.

paulrutter commented 1 month ago

Created https://github.com/apache/felix-dev/pull/322

jansupol commented 1 month ago

You are right, Multi-Release: true is missing in the MANIFEST.MF.

paulrutter commented 1 month ago

Right, as in, it's an issue in the maven-bundle-plugin? Or right, it's an issue in Jersey (as well)?

Because using bndlib 7.0.0 seems to work, as it supports MR jars.

jansupol commented 1 month ago

It may be an issue in Jersey for certain environments depending on the Multi-Release field. Your environment may be one of them.

paulrutter commented 1 month ago

Ok, when upgrading bndlib to 7.0.0 i didn’t notice any build errors anymore though, so not sure what the issue would be then. I will try 3.1.7 in our application and let you know if it works properly or not.

We're running java 21, with Apache Felix as osgi container and Jetty 12 EE 10 btw.

paulrutter commented 1 month ago

@jansupol I ran the feature build containing 3.1.7 this morning and although compiling and building went fine, the application doesn't start properly due to an OSGi bundle not being able to start.

org.osgi.framework.BundleException: Unable to resolve com.abc.services.openapi [53](R 53.0): missing requirement [com.abc.services.openapi [53](R 53.0)] osgi.extender; (&(osgi.extender=osgi.cdi)(version>=1.0.0)(!(version>=2.0.0))) Unresolved requirements: [[com.abc.services.openapi [53](R 53.0)] osgi.extender; (&(osgi.extender=osgi.cdi)(version>=1.0.0)(!(version>=2.0.0)))]

I would have expected the OSGi bundle containing Jersey would fail (that one just starts properly). Is this in line with the problems you would expect?

jansupol commented 1 month ago

No, this looks like some other issue, osgi.cdi module of a wrong version or missing.

paulrutter commented 1 month ago

Ok, i will investigate it further and let you know.

paulrutter commented 1 month ago

Sorry for the confusion @jansupol, that OSGi error is indeed unrelated. After fixing that one, the application just starts properly with Jersey 3.1.7.