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

slf4j missing uses constraints #682

Closed
jonahgraham opened this issue Nov 21, 2022 · 20 comments · Fixed by #981
Closed

slf4j missing uses constraints #682

jonahgraham opened this issue Nov 21, 2022 · 20 comments · Fixed by #981

Comments

@jonahgraham
Copy link
Contributor

The SLF4J is missing uses constraints. This leads to runtime errors like this (I added line breaks for readability) if there are multiple versions of slf4j installed.

loader constraint violation: 
  when resolving method 'org.slf4j.ILoggerFactory org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()' 
  the class loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @3a07fd19 of the current class, 
    org/slf4j/LoggerFactory, and 
  the class loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @773560cf for the method's defining class, 
    org/slf4j/impl/StaticLoggerBinder, 
  have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
  (org.slf4j.LoggerFactory is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @3a07fd19,
       parent loader 'platform'; 
   org.slf4j.impl.StaticLoggerBinder is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @773560cf, 
       parent loader 'platform')
@jonahgraham
Copy link
Contributor Author

A workaround is to make sure that only a single version of SLF4J is installed.

@HannesWell
Copy link
Member

A workaround is to make sure that only a single version of SLF4J is installed.

That should be the goal also to ensure the logging works correctly.
But having technical support to enforce this would be still good.

On the other hand that would make it impossible to use two libraries where one requires strictly slf4j<2 (because it has not yet updated its import-package ranges) and the other requires slf4j>=2. The logging will then likely be flaky, but if one does not care about that, it is not possible anymore.

@akurtakov
Copy link
Member

Is there anything to do on releng side here or it can be closed?

@jonahgraham
Copy link
Contributor Author

Is there anything to do on releng side

I think so, the slf4j that platform now pulls in has no uses clauses (unlike the slf4j that orbit repackages). This leads to wiring errors.

I understand the move away from orbit, but if the upstream package is missing uses clauses and we encourage consumers of slf4j to use import package, then we should ensure that uses clauses exist.

@akurtakov
Copy link
Member

I hope that someone will open issue against slf4j requesting uses clauses to be added.

@jonahgraham
Copy link
Contributor Author

https://jira.qos.ch/browse/SLF4J-574

@HannesWell
Copy link
Member

Thank you Jonah for string qos-ch/slf4j#324.
Just adding it to have a cross-reference.

@akurtakov
Copy link
Member

New slf4j version with Jonah's change has been released qos-ch/slf4j@v_2.0.5...v_2.0.6 . Please provide the needed updates so we can finish this one.

@jonahgraham
Copy link
Contributor Author

@HannesWell can you make this change in platform?

@ruspl-afed
Copy link
Contributor

Does it mean that Platform is going to switch to SLF4J 2.x?

@HannesWell
Copy link
Member

@HannesWell can you make this change in platform?

Yes, I do. But after looking in more detail in your change I noticed that it for example changed the BSN. At the moment slf4j has now a mixtured of generating the manifest and using static manifest files under version control. I have started to prepare a follow-up on your change and plan to complete it this evening, that completely migrates to generating the manifests, thus removing all static manifest files.

Does it mean that Platform is going to switch to SLF4J 2.x?

Yes, we do. See #588

But I'm considering (and bndtools/bnd#5477 (comment) strengthened this consideration) to ask SLF4J to export its packages in a 1.7.x version and 2 version, so that libaries that import slf4j below version 2 can just use slf4j-2 without changes.

@HannesWell
Copy link
Member

@HannesWell can you make this change in platform?

Yes, I do. But after looking in more detail in your change I noticed that it for example changed the BSN. At the moment slf4j has now a mixtured of generating the manifest and using static manifest files under version control. I have started to prepare a follow-up on your change and plan to complete it this evening, that completely migrates to generating the manifests, thus removing all static manifest files.

Created qos-ch/slf4j#327.

@merks
Copy link
Contributor

merks commented Dec 16, 2022

I noticed this resolution failure (in Tycho 4.0.0-SNAPSHOT) when trying to fully resolve the requirements of slf4j-api version 2.0.6

Missing requirement: org.slf4j.api 2.0.6 requires 'osgi.extender; (&(osgi.extender=osgi.serviceloader.processor)(version>=1.0.0)(!(version>=2.0.0)))' but it could not be found

What is supposed to satisfy that requirement?

@HannesWell
Copy link
Member

HannesWell commented Dec 16, 2022

The (reference) Implementation of the OSGi ServiceLoader Mediator specification I usually use is Apache Aries SPI-fly:

That should provide that capabilty.

@merks
Copy link
Contributor

merks commented Dec 16, 2022

Okay, that helps! With that included, it gets to this failure:

Missing requirement: org.slf4j.api 2.0.6 requires 'osgi.serviceloader; (osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvider)' but it could not be found

@HannesWell
Copy link
Member

Okay, that helps! With that included, it gets to this failure:

Missing requirement: org.slf4j.api 2.0.6 requires 'osgi.serviceloader; (osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvider)' but it could not be found

Do you have a recent SLF4J-provider in the TP? In case of Eclipse-Platform we probably want to only reference to no-op provider and let actual application/product builds choose a suitable one for them:
https://mvnrepository.com/artifact/org.slf4j/slf4j-nop/2.0.6

@merks
Copy link
Contributor

merks commented Dec 16, 2022

That fixes the problem! You're the best. 🚀

@akurtakov
Copy link
Member

Should this one be closed now?

@HannesWell
Copy link
Member

Should this one be closed now?

Unfortunately the metadata of the current slf4j-release are still different than before in same parts:

@HannesWell can you make this change in platform?

Yes, I do. But after looking in more detail in your change I noticed that it for example changed the BSN. At the moment slf4j has now a mixtured of generating the manifest and using static manifest files under version control. I have started to prepare a follow-up on your change and plan to complete it this evening, that completely migrates to generating the manifests, thus removing all static manifest files.

Therefore I'm not sure if we should use that version.
I created qos-ch/slf4j#327 to fix that but that change was considered to large. As requested I created a reduced follow-up qos-ch/slf4j#330, but that did not yet get any attention.
So if anyone of you can help to motivate the SLF4J-maintainer for the latter PR that would help.
Otherwise we have to go with the changed metadata.

HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue Mar 17, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j version.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
@HannesWell
Copy link
Member

The mentioned SLF4J PR is merged and released as slf4j-api 2.0.7.
Created #981 to update. With that the metadata should now be fine.

HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue Mar 17, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j-api version in use.
Since version 2 the slf4j-api uses the ServiceLoader mechanism and
requires a 'Service Loader Mediator' implementation in an OSGi runtime.
Therefore the Apache Aries SPI Fly Dynamic Weaving Bundle is added with
this change.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue Mar 25, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j-api version in use.
Since version 2 the slf4j-api uses the ServiceLoader mechanism and
requires a 'Service Loader Mediator' implementation in an OSGi runtime.
Therefore the Apache Aries SPI Fly Dynamic Weaving Bundle is added with
this change.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue Apr 7, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j-api version in use.
Since version 2 the slf4j-api uses the ServiceLoader mechanism and
requires a 'Service Loader Mediator' implementation in an OSGi runtime.
Therefore the Apache Aries SPI Fly Dynamic Weaving Bundle is added with
this change.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue Apr 11, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j-api version in use.
Since version 2 the slf4j-api uses the ServiceLoader mechanism and
requires a 'Service Loader Mediator' implementation in an OSGi runtime.
Therefore the Apache Aries SPI Fly Dynamic Weaving Bundle is added with
this change.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue Apr 14, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j-api version in use.
Since version 2 the slf4j-api uses the ServiceLoader mechanism and
requires a 'Service Loader Mediator' implementation in an OSGi runtime.
Therefore the Apache Aries SPI Fly Dynamic Weaving Bundle is added with
this change.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue Apr 15, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j-api version in use.
Since version 2 the slf4j-api uses the ServiceLoader mechanism and
requires a 'Service Loader Mediator' implementation in an OSGi runtime.
Therefore the Apache Aries SPI Fly Dynamic Weaving Bundle is added with
this change.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue May 10, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j-api version in use.
Since version 2 the slf4j-api uses the ServiceLoader mechanism and
requires a 'Service Loader Mediator' implementation in an OSGi runtime.
Therefore the Apache Aries SPI Fly Dynamic Weaving Bundle is added with
this change.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this issue May 15, 2023
Since version 2.0.7 the slf4j.api bundle exports the user-api package
'org.slf4j' in version 2.x.y and 1.7.36.
This allows to also use libraries, which are programmed against slf4j-1
and import the package 'org.slf4j' with an exclusive upper bound of 2
like '[1.7,2)', with the slf4-api version 2 in OSGi environments.

According to SLF4J the client/user facing API is compatible with
slf4j-1:
- https://www.slf4j.org/faq.html#changesInVersion200
- https://www.slf4j.org/faq.html#compatibility

Only the logging-backends/bindings/providers have match the requirements
of the specific slf4j-api version in use.
Since version 2 the slf4j-api uses the ServiceLoader mechanism and
requires a 'Service Loader Mediator' implementation in an OSGi runtime.
Therefore the Apache Aries SPI Fly Dynamic Weaving Bundle is added with
this change.

The corresponding SLF4J issue and change is
- https://jira.qos.ch/browse/SLF4J-579
- qos-ch/slf4j#331

Fixes eclipse-platform#588
Fixes eclipse-platform#682
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants