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

Workspace template fails to read files from github in some Eclipse configurations #6431

Open
scottslewis opened this issue Jan 19, 2025 · 21 comments

Comments

@scottslewis
Copy link
Contributor

I'm opening this bug here (even though I think the root cause is in egit or other Eclipse projects) because the problem shows up for bndtools 7.1 users that install bndtools 7.1 into eclipse packages or the SDK with git installed.

When creating a new workspace via File->New->Bnd OSGi Workspace

Image

Image

In environments with egit/jgit installed the following error occurs in Preview Changes

Image

Note that the first time, the Preview Page contents are empty with no error message as shown in the previous screenshot, but if the Preview Page will be empty but the shown error message will be present.

Error: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory is not from bndtools code, but I believe it's from jgit's usage of apache httpclient 4.5...see below.

Nothing (e.g. stack) is reported to the Eclipse Error view or osgi log. I suspect the reason for this is that in the WorkspacePreviewPage class:

The Exception message is not getting logged and only sets the errorMessage. It would be helpful for debugging this if the Exception caught in WorkspacePreviewPage logged the exception and stack trace.

With configuration...

OS: Windows/x64
Java version: 17

  1. The Eclipse Committers package for 2024-12 from: https://www.eclipse.org/downloads/packages/release/2024-12/r/eclipse-ide-eclipse-committers
  2. Bndtools 7.1 from https://bndtools.org/bndtools.p2.repo/7.1.0/
  3. ECF 3.15.3 from https://download.eclipse.org/rt/ecf/3.15.3/site.p2

...the problem described above occurs.

While with the Eclipse SDK as base...i.e.

  1. Eclipse 4.34/2024-12 SDK as base...i.e. download here: https://download.eclipse.org/eclipse/downloads/drops4/R-4.34-202411201800/
  2. Eclipse EGit 7.1.0 from 2024-12 repo at: https://download.eclipse.org/releases/2024-12
  3. Bndtools 7.1 from https://bndtools.org/bndtools.p2.repo/7.1.0/
  4. ECF 3.15.3 from https://download.eclipse.org/rt/ecf/3.15.3/site.p2

...the problem described above does not occur.

There might be more than one copy of Apache httpclient 4.5.* in the Eclipse Committers package that is causing a class initialization failure in jgit, that results in the exception bubbling up to bndtools 7.1 workspace template when attempting reading from github.

org.apache.http.conn.ssl.SSLConnectionSocketFactory exists in 4.5.* of httpclient, but does is in a different package in httpclient5 (which is now used by Eclipse 4.34 for install update) i.e. org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.

@scottslewis
Copy link
Contributor Author

After additional install testing, the original problem (failed jgit-based github files download with Cannot initialize class error) appears to occur only if:

Jgit 7.1.0 is installed
M2e version from 2024-12 is installed

That is, if only egit/jgit is installed (not m2e) as described by above comment

....then the problem does not occur.

If, however, egit is installed (required by bndtools), and m2e is installed (either via package, explicit install, or via bndtools m2e extension) then the problem described above occurs.

Many (most?) of the packages produced by the Eclipse Packaging Project currently (e.g. Java, Committers, others) currently include both m2e and egit. If bndtools 7.1 is installed into any of those packages, then I would predict this same problem to occur.

@ewillink
Copy link

ewillink commented Jan 20, 2025

Quite possibly related. With EGIT 2024-12 I get the anomalies below. I use m2e from 2024-12 releases. The Eclipse configurations shows that I have bntools.api and bbndtools.jareditor installed.

Image

The error log shows

java.lang.ExceptionInInitializerError
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:151)
at org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory$HttpClientSession.configure(HttpClientConnectionFactory.java:81)
at org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory$HttpClientSession.configure(HttpClientConnectionFactory.java:1)
at org.eclipse.jgit.transport.TransportHttp.httpOpen(TransportHttp.java:1062)
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:651)
at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:465)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:153)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:105)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1458)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:238)
at org.eclipse.egit.core.op.FetchOperation.run(FetchOperation.java:134)
at org.eclipse.egit.ui.internal.fetch.FetchOperationUI.execute(FetchOperationUI.java:111)
at org.eclipse.egit.ui.internal.fetch.FetchOperationUI$1.performJob(FetchOperationUI.java:137)
at org.eclipse.egit.ui.internal.jobs.RepositoryJob.run(RepositoryJob.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.apache.commons.logging.LogConfigurationException: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'org.apache.commons.logging.LogFactory'. The conflict is caused by the presence of multiple LogFactory classes in incompatible classloaders. Background can be found in http://commons.apache.org/logging/tech.html. If you have not explicitly specified a custom LogFactory then it is likely that the container has set one without your knowledge. In this case, consider using the commons-logging-adapters.jar file or specifying the standard LogFactory from the command line. Help can be found @http://commons.apache.org/logging/troubleshooting.html.)
at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1154)
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:960)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:957)
at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:624)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at org.apache.http.conn.ssl.AbstractVerifier.(AbstractVerifier.java:61)
at org.apache.http.conn.ssl.AllowAllHostnameVerifier.(AllowAllHostnameVerifier.java:44)
at org.apache.http.conn.ssl.AllowAllHostnameVerifier.(AllowAllHostnameVerifier.java:46)
... 15 more
Caused by: java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'org.apache.commons.logging.LogFactory'. The conflict is caused by the presence of multiple LogFactory classes in incompatible classloaders. Background can be found in http://commons.apache.org/logging/tech.html. If you have not explicitly specified a custom LogFactory then it is likely that the container has set one without your knowledge. In this case, consider using the commons-logging-adapters.jar file or specifying the standard LogFactory from the command line. Help can be found @http://commons.apache.org/logging/troubleshooting.html.
at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1108)
... 23 more

I had to use 2024-09 to add QVTo and MoDisco touches for 2025-03.

@ewillink
Copy link

This looks like eclipse-orbit/orbit-simrel#40 (comment)

@ewillink
Copy link

ewillink commented Jan 20, 2025

It seems that transitively SimRel has a bad org.apache.commons.logging:1.2.0.v20180409-150 from the old Orbit. While arbitrary Eclipse add-ons may be free to add inconsistent contributions, surely everything in SimRel MUST be compatible? Projects that really need a bad variant should workaround an officious SimRel aggregator by including the bad variant as private internal libraries. (Historical imports from the old Orbit for products that have not been refreshed are surely different versions and so not a problem?)

@merks
Copy link

merks commented Jan 20, 2025

I did previously explain a workaround for how to exclude/remove the bad variant, but I can't for the life of me find where anymore. So I described it again here for future reference

eclipse-orbit/orbit-simrel#40 (comment)


I hope never to have to explain the following again; hope dies last.

Nothing needs the bad variant, i.e., 1.2.0.v20180409-150. It simply has a higher version so will generally be installed when available in a p2 repository being used during an install or an update. In addition, it will not be downgraded when already installed. Neither SimRel 2024-09 nor 2024-12 contain it so there isn't much that can be done on that end. Note too that the bad variant is only a problem when a newer 1.3.x version is also installed. Here we see both 1.2.x and 1.3.x versions along the things strictly requiring those versions:

Image

Note how org.apache.httpcomponents.httpclient excludes the 1.3.0 version of the package. (Why do they do that?) Looking at all the dependencies org.apache.httpcomponents.httpclient 4.x, I would not hold my breath that this bundle will be eliminated anytime in the foreseeable future:

Image

In any case, it's proven impossible to eliminate all older Orbit content despite all efforts toward that goal:

eclipse-simrel/simrel.build#438

If only I could get people to stop including 3rd party bundles in features and use package requirements instead of bundle requirements.

In any case, those steps include explicitly excluding, via Exclusion Rules, some outdated versions for problematic ones where the outdated version has a higher version number:

Image

So surely yes, everything in SimRel is compatible with the 1.2.0 version because the officious SimRel aggregator excludes the unwanted variant.

@chrisrueger
Copy link
Contributor

I have checked with the local bndtools Development Environment and I see the mentioned problematic org.apache.commons.logging:1.2.0.v20180409-1502

g! lb logg
START LEVEL 1
   ID|State      |Level|Name
   37|Active     |    1|Apache Commons Logging (1.2.0.v20180409-1502)|1.2.0.v20180409-1502

I think it gets pulled in via our Eclipse 4.25 (2022-09) handcrafted repo.
https://bndtools.jfrog.io/bndtools/bnd-build/eclipse/4.25/index.xml.gz

Then I check my host Eclipse (Version: 2023-09 (4.29.0) and also Version: 2024-12 (4.34.0))

In both cases I see
Image

Image

@peterkir Since @merks mentiones Oomph in eclipse-orbit/orbit-simrel#40 (comment) : is this something relevant for our oomph stuff you added recently for bndtools ?

@ewillink In eclipse-orbit/orbit-simrel#40 (comment) you mentioned that you got a workaround working.
Could you elaborate a bit more here?

In conclusion:

  • I am not sure I understand if or what there is bndtools can do.
  • We could add more logging as @scottslewis requests to be able to see the stacktrace somewhere

Any thoughts?

@ewillink
Copy link

@ewillink In eclipse-orbit/orbit-simrel#40 (comment) you mentioned that you got a workaround working.
Could you elaborate a bit more here?

I did pretty much exactly as @emerks directed; the instructions are pretty precise. My additional eclipse-orbit/orbit-simrel#40 (comment) NBs a couple of impatient mistakes that I made and an observation. All that I might add is that you need to install Oomph Setup SDK from 2024-12 - https://download.eclipse.org/releases/2024-12.

@merks
Copy link

merks commented Jan 20, 2025

@chrisrueger

The issue has nothing to do with Oomph; you can just use Oomph to help work around the problem. The fundamental problem is that org.apache.commons.logging:1.2.0.v20180409-1502 installed along with org.apache.commons.commons-logging:1.3.3 just doesn't work. And, as I said, if the 1.2.0.v20180409-1502 is visible in any repo it will tend to be installed in favor of 1.2.0, so best BND not include that it its repository. Also, if anything exactly requires 1.2.0.v20180409-1502 then it definitely will be installed and you cannot exclude it, so best not include that bundle in any feature and best to use package imports with as wide a version range as possible.

The problem with this problem is people keep wanting to push the blame somewhere to a single location. So "old Orbit" is to blame for producing poor/bad metadata. Httpclient is to blame for using such a narrow version range. Apache is to blame for making the bundle name for 1.3 different from the bundle name for 1.2. A whole bunch of people are to blame for continuing to use the old httpclient. A whole bunch of people are to blame for not using package imports. If there were a new 1.2.x version created at Maven central, that would avoid the whole problem too, but that will never happen.

So I think this problem will never really die...

@laeubi
Copy link
Contributor

laeubi commented Jan 20, 2025

Any thoughts?

@chrisrueger , @scottslewis (and others with that problem)

can you please start eclipse with -console option (or go to Console View and open OSGi Host Console)?

Then type in exportFrameworkState <some file path>/export.state and upload the files here, this will contain all bundles+headers+resolve state so usually nothing "secret".

Also please do:

ss logging

and for each bundle like

id	State       Bundle
51	RESOLVED    org.apache.commons.logging_ wahtever version
... maybe more ...

perform

wires <id>

and post the output here if possible.

@chrisrueger
Copy link
Contributor

@laeubi

I do not have this problem mentioned by @scottslewis, but maybe for comparison I post my stuff here:
Eclipse Version: 2024-12 (4.34.0)

export.state.zip

g! ss logging
"Framework is launched."


id	State       Bundle
54	RESOLVED    org.apache.commons.logging_1.2.0.v20180409-1502
g! wires 54
Bundle org.apache.commons.logging 1.2.0.v20180409-1502:
is wired to:
	 - org.eclipse.jetty.servlet-api 4.0.6
	   - because of Import-Package: javax.servlet; resolution:="optional"
	 - org.eclipse.osgi 3.22.0.v20241030-2121
	   - because of Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.2))"
and is consumed by:
	 - org.apache.ant 1.10.15.v20240901-1000
	   - because it Import-Package: org.apache.commons.logging; resolution:="optional"
	 - org.apache.commons.httpclient 3.1.0.v20240401-1000
	   - because it Import-Package: org.apache.commons.logging; version="[1.0.0,2.0.0)"
	 - org.apache.httpcomponents.httpclient 4.5.14
	   - because it Import-Package: org.apache.commons.logging; version="[1.1.0,1.3.0)"
	 - org.apache.xmlgraphics 2.10.0.v20241009-1200
	   - because it Import-Package: org.apache.commons.logging; version="[1.0.0,2.0.0)"
	 - org.eclipse.mylyn.commons.net 4.5.0.v20241002-1142
	   - because it Import-Package: org.apache.commons.logging; version="[1.0.4,2.0.0)"
	 - org.eclipse.mylyn.commons.repositories.http.core 4.5.0.v20241002-1142
	   - because it Import-Package: org.apache.commons.logging; version="[1.0.4,2.0.0)"
	 - org.eclipse.mylyn.tasks.ui 4.5.0.v20241002-1142
	   - because it Import-Package: org.apache.commons.logging; version="[1.0.4,2.0.0)"
	 - org.eclipse.oomph.setup.sync 1.17.0.v20240317-0755
	   - because it Import-Package: org.apache.commons.logging; version="[1.2.0,2.0.0)"
Image

@scottslewis
Copy link
Contributor Author

scottslewis commented Jan 20, 2025

The problem with this problem is people keep wanting to push the blame somewhere to a single location. So "old Orbit" is to
blame for producing poor/bad metadata. Httpclient is to blame for using such a narrow version range. Apache is to blame for
making the bundle name for 1.3 different from the bundle name for 1.2. A whole bunch of people are to blame for continuingto
use the old httpclient. A whole bunch of people are to blame for not using package imports. If there were a new 1.2.x version
created at Maven central, that would avoid the whole problem too, but that will never happen.

So I think this problem will never really die...

Wouldn't the commons logging project lead be in a position to address? For example, remove from maven central the offending version.

I suppose it would be nice to have some OSS industry-wide policy wrt library//dependency deprecation (i.e. 'standards'), but maybe it's time to produce something workable as an OSS dev community so that such cross-org, cross-project, cross-vendor vulnerabilities can at least be addressed in principle. Not a short-term fix, obviously, but probably needed for (e.g.) CSA.

@merks
Copy link

merks commented Jan 21, 2025

As far as I understand it nothing can ever be removed from maven central. Moreover, we see that this bundle would stop working without 1.2.x, or would need 1.1.x which is an even lower version that 1.2.0.x so would not help solve any problem.

	 - org.apache.httpcomponents.httpclient 4.5.14
	   - because it Import-Package: org.apache.commons.logging; version="[1.1.0,1.3.0)"

A new version of httpclient that didn't exclude 1.3.0 would help stamp out this problem.

Note too that the offending version is not the one at maven central but the one that Orbit produced by discarding the OSGi metadata from the one in maven central and replacing it with something else.

@scottslewis

I think it would be helpful to see the information that @laeubi requested in #6431 (comment).

@laeubi
Copy link
Contributor

laeubi commented Jan 21, 2025

A new version of httpclient that didn't exclude 1.3.0 would help stamp out this problem.

I already talked with the httpcomponents people about further improvements and osgi support and basically:

  1. They have no resources
  2. They have no interest
  3. Contributions are welcome (maybe)
  4. http4 is essential not worked on anymore

Beside that one might want to blame the OSGi resolver to build an incompatible classpace but without the requested information from the actual problem its hard to guess.

@scottslewis
Copy link
Contributor Author

@merks

I think it would be helpful to see the information that @laeubi requested in https://github.com/bndtools/bnd/>issues/6431#issuecomment-2602657576.

Then please generate and post here. I've expended my/ECF's time budget on problems caused purely by the inability for other projects to work cooperatively to provide a functioning and secure Eclipse.

A new version of httpclient that didn't exclude 1.3.0 would help stamp out this problem.

I already talked with the httpcomponents people about further improvements and osgi support and basically:

1. They have no resources

2. They have no interest

3. Contributions are welcome (maybe)

4. http4 is essential not worked on anymore

Hmmm. Where have I heard this set of responses before? Could it be from (EF and non-EF) projects that the entire Eclipse ecosystem depend upon? Maybe they have a point.

FWIW: Eclipse (via ECF filetransfer API) has for 2+ years included an impl of httpclient (5) and for 15+ years now that has exposed a single, stable, reliable, async file transfer API to clients (e.g. p2, oomph at least), AND maintained/updated provider implementations like Apache httpclient 3,4,5, etc. so that conflicts such as this could be easily avoided by Eclipse-based projects and products.

@merks
Copy link

merks commented Jan 23, 2025

Lack of resource is indeed a pervasive problem, being helpful is not without cost, and even things that are easy don't necessarily get done. It is an imperfect world full of imperfect people.

I installed the Eclipse Eierlegende Wollmilchsau and added the following to the installation.setup, saved, and invoked Help -> Perform Setup Tasks:

<?xml version="1.0" encoding="UTF-8"?>
<setup.p2:P2Task
    xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:setup.p2="http://www.eclipse.org/oomph/setup/p2/1.0">
  <requirement
      name="org.apache.commons.logging"/>
  <repository
      url="https://download.eclipse.org/efxclipse/runtime-released"/>
</setup.p2:P2Task>

Image

I believe that doing that for any Eclipse installation will reproduce the problem because it updates the installation to use logging 1.2.0.v20180409-1502.

Here is the requested details.

g! ss logging
"Framework is launched."


id      State       Bundle
135     RESOLVED    org.apache.commons.commons-logging_1.3.4
2296    RESOLVED    org.eclipse.xtext.logging_2.38.0.v20250106-0801
                    Master=155
2404    RESOLVED    org.apache.commons.logging_1.2.0.v20180409-1502
g! wires 2404
Bundle org.apache.commons.logging 1.2.0.v20180409-1502:
is wired to:
         - org.apache.commons.commons-logging 1.3.4
           - because of Import-Package: org.apache.commons.logging.impl; version="[1.2.0,2.0.0)"; resolution:="optional"
         - org.apache.log4j 1.2.26
           - because of Import-Package: org.apache.log4j; resolution:="optional"
         - org.eclipse.jetty.servlet-api 4.0.6
           - because of Import-Package: javax.servlet; resolution:="optional"
         - org.eclipse.osgi 3.23.0.v20241212-0858
           - because of Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.2))"
and is consumed by:
         - org.apache.httpcomponents.httpclient 4.5.14
           - because it Import-Package: org.apache.commons.logging; version="[1.1.0,1.3.0)"
         - org.eclipse.mylyn.commons.repositories.http.core 4.6.0.v20241229-1209
           - because it Import-Package: org.apache.commons.logging; version="[1.0.4,2.0.0)"
         - org.eclipse.php.composer.api 8.2.0.202311292129
           - because it Require-Bundle: org.apache.commons.logging
         - org.eclipse.php.composer.core 8.2.0.202311292129
           - because it Require-Bundle: org.apache.commons.logging
g! wires 135
Bundle org.apache.commons.commons-logging 1.3.4:
is wired to:
         - org.apache.aries.spifly.dynamic.bundle 1.3.7
           - because of Import-Package: org.apache.aries.spifly; resolution:="dynamic"; x.dynamically.added:="true"
           - because of Require-Capability: osgi.extender; filter:="(&(osgi.extender=osgi.serviceloader.processor)(version>=1.0.0)(!(version>=2.0.0)))"; resolution:="optional"
         - org.apache.log4j 1.2.26
           - because of Import-Package: org.apache.log4j; version="[1.2.15,2.0.0)"; resolution:="optional"
         - org.eclipse.jetty.servlet-api 4.0.6
           - because of Import-Package: javax.servlet; version="[2.1.0,5.0.0)"; resolution:="optional"
         - org.eclipse.osgi 3.23.0.v20241212-0858
           - because of Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.8))"
         - slf4j.api 2.0.16
           - because of Import-Package: org.slf4j; version="[1.7.0,3.0.0)"; resolution:="optional"
           - because of Import-Package: org.slf4j.spi; version="[1.7.0,3.0.0)"; resolution:="optional"
and is consumed by:
         - org.apache.ant 1.10.15.v20240901-1000
           - because it Import-Package: org.apache.commons.logging; resolution:="optional"
         - org.apache.axis 1.4.1.v20231107-0937
           - because it Import-Package: org.apache.commons.logging; resolution:="optional"
         - org.apache.commons.discovery 0.5.0
           - because it Import-Package: org.apache.commons.logging
         - org.apache.commons.httpclient 3.1.0.v20240401-1000
           - because it Import-Package: org.apache.commons.logging; version="[1.0.0,2.0.0)"
         - org.apache.commons.logging 1.2.0.v20180409-1502
           - because it Import-Package: org.apache.commons.logging.impl; version="[1.2.0,2.0.0)"; resolution:="optional"
         - org.apache.velocity 1.7.0
           - because it Import-Package: org.apache.commons.logging; resolution:="optional"
         - org.apache.xmlgraphics 2.10.0.v20241009-1200
           - because it Import-Package: org.apache.commons.logging; version="[1.0.0,2.0.0)"
         - org.eclipse.emf.mwe.core 1.15.0.v20250104-0646
           - because it Import-Package: org.apache.commons.logging; version="1.3.4"
         - org.eclipse.emf.mwe.utils 1.15.0.v20250104-0646
           - because it Import-Package: org.apache.commons.logging; version="1.3.4"
         - org.eclipse.jst.server.preview.adapter 1.2.300.v202408152039
           - because it Import-Package: org.apache.commons.logging
         - org.eclipse.mylyn.commons.net 4.6.0.v20241229-1209
           - because it Import-Package: org.apache.commons.logging; version="[1.0.4,2.0.0)"
         - org.eclipse.mylyn.tasks.ui 4.6.0.v20241229-1209
           - because it Import-Package: org.apache.commons.logging; version="[1.0.4,2.0.0)"
         - org.eclipse.oomph.setup.sync 1.18.0.v20250103-1108
           - because it Import-Package: org.apache.commons.logging; version="[1.2.0,2.0.0)"
         - org.eclipse.wst.server.preview 1.3.100.v202408152039
           - because it Import-Package: org.apache.commons.logging; version="[1.2.0,2.0.0)"
         - org.eclipse.wst.server.preview.adapter 1.2.200.v202408152039
           - because it Import-Package: org.apache.commons.logging
         - org.eclipse.wst.wsi 1.1.700.v202408150414
           - because it Import-Package: org.apache.commons.logging; version="[1.2.0,2.0.0)"
         - org.eclipse.wst.xsl.jaxp.debug 1.1.200.v202408140326
           - because it Import-Package: org.apache.commons.logging; version="[1.2.0,2.0.0)"
         - org.eclipse.wst.xsl.xalan 1.1.200.v202409142305
           - because it Import-Package: org.apache.commons.logging; version="[1.2.0,2.0.0)"
         - org.eclipse.xtext.common.types 2.38.0.v20250106-0801
           - because it Import-Package: org.apache.commons.logging; version="1.0.4"; resolution:="optional"
         - org.eclipse.xtext.purexbase 2.38.0.v20250106-0801
           - because it Import-Package: org.apache.commons.logging
         - org.eclipse.xtext.purexbase.ui 2.38.0.v20250106-0801
           - because it Import-Package: org.apache.commons.logging
         - org.eclipse.xtext.ui.codetemplates 2.38.0.v20250106-0801
           - because it Import-Package: org.apache.commons.logging
         - org.eclipse.xtext.xtext.generator.dependencies 2.38.0.v20250106-0801
           - because it Require-Bundle: org.apache.commons.commons-logging; bundle-version="1.3.4"; visibility:="reexport"
         - org.freemarker.freemarker 2.3.32.stable
           - because it Import-Package: org.apache.commons.logging; resolution:="optional"

The offending detail appears to be the following:

Bundle org.apache.commons.logging 1.2.0.v20180409-1502:
is wired to:
         - org.apache.commons.commons-logging 1.3.4
           - because of Import-Package: org.apache.commons.logging.impl; version="[1.2.0,2.0.0)"; resolution:="optional"

That's not surprising given the bounds on the imported export which presume that all 1.x versions will provide a compatible internal implementation:

Image

I wonder if the org.apache.commons package is not also bound to 1.3.0 and if not why not? In any case, this seems a problem that has been waiting to happen since 2018...

@laeubi
Copy link
Contributor

laeubi commented Jan 23, 2025

because of Import-Package: org.apache.commons.logging.impl; version="[1.2.0,2.0.0)"

This is most likely wrong and should be something like version="[1.2.0,1.3.0)" (provider range), but it sounds not useful anyways as only API should be substituted and not implementations.

I wonder if the org.apache.commons package is not also bound to 1.3.0 and if not why not?

First the import is optional (so the resolver can discard this if it is in conflict) what is another strange detail, I don't think optional is forbidden but does not make much sense for a substitution package.

Next thing is use clauses, if the exported package do not contain use clauses, then essentially all packages are seen as completely independent and unrelated, that means resolver can (and will!) resolve them eventually to different providers.

I'll try to condense a test-case from this maybe then one can tell more details (see also eclipse-equinox/equinox#670).

@laeubi
Copy link
Contributor

laeubi commented Jan 23, 2025

It was not completely clear to me but if we look here:

If a bundle has both import and export definitions for the same package, then the Framework needs to decide which to choose.

It must first try to resolve the overlapping import definition. The following outcomes are possible:

  • External - If this resolves to an export statement in another bundle, then the overlapping export definition in this bundle is discarded.
  • Internal - If it is resolved to an export statement in this bundle, then the overlapping import definition in this bundle is discarded.
  • Unresolved - There is no matching export definition. In this case the framework is free to discard either the overlapping export definition or overlapping import definition in this bundle. If the export definition is discarded and the import definition is not optional then the bundle will fail to resolve.

The above only applies to the import and export package definitions of a bundle. For namespaces other than osgi.wiring.package, a requirement definition of a bundle may be wired to a capability definition of that same bundle.

Then optional is useful for the last case but I really doubt the author of that information really has this in mind, this will only apply if the export does not match the import and there is no external provider for the package ... I literally can't think of any case where it might be useful and working but it is not forbidden.

@laeubi
Copy link
Contributor

laeubi commented Jan 23, 2025

I looked further into this and it seems the main issue is that 1.3.4 is not having a use-clause on the package export.

I have created LOGGING-198 for this.

So if there would be a 1.3.5 with proper use clauses this would avoid the issue (or at least give a resolution failure), currently the org.apache.commons.logging and org.apache.commons.logging.impl are independent packages, so the impl is resolved to the higher version (that has a different classloader).

@laeubi
Copy link
Contributor

laeubi commented Jan 23, 2025

@chrisrueger
Copy link
Contributor

Just for reference, there is also this: eclipse-packaging/packages#270

@merks
Copy link

merks commented Jan 24, 2025

I'm not sure from where the bad version of commons.logging is coming but we've taken steps to ensure that is impossible to install the bad version in any 2025-03 package:

eclipse-packaging/packages#270 (comment)

As far as I can tell, there is nothing BND can do to fix this problem, short of what EPP has already done.

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

No branches or pull requests

5 participants