ppkarwasz commented on PR #1165:
URL: https://github.com/apache/logging-log4j2/pull/1165#issuecomment-1364420974

   OSGI resolves a bundle's dependencies **before** it loads any class from the 
bundle. Running the tests in `log4j-osgi` with `-Dfelix.version=4.4.1` (which 
contains OSGI Framework API 1.7) I get an error like this:
   
   ```
   org.osgi.framework.BundleException: Unresolved constraint in bundle 
org.apache.logging.log4j.api [11]: Unable to resolve 11.0: missing requirement 
[11.0] osgi.wiring.package; 
(&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(version>=2.0.0)))
   ```
   
   Probably, what is happening in your test is that `log4j-api` is not 
initialized inside the OSGI container, but is contained in the tests runtime. 
Log4j2 is initialized before the OSGI framework detect the version 
incompatibility.
    the
   Amore stable solution to this problem would be to set the `OSGI_AVAILABLE` 
field from the bundle's activator. This way we have a garantee that 
`OSGI_AVAILABLE` is set if and only if the activator of the bundle has been 
called.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to