I'm trying to ran Karaf 4.4.3 with my app which is using Log4j2 v2.22.1. However, I got and exception:
Caused by: org.apache.felix.resolver.reason.ReasonException: Unable to resolve com.my.bundle/4.1.0.SNAPSHOT: missing requirement [com.my.bundle/4.1.0.SNAPSHOT] osgi.wiring.package; filter:="(&(osgi.wiring.package=org.slf4j)(version>=2.0.0)(!(version>=3.0.0)))"
What I have already checked. I have pax-logging libraries in system directory:
$ find . | grep pax-logging
./system/org/ops4j/pax/logging/pax-logging-log4j2
./system/org/ops4j/pax/logging/pax-logging-log4j2/2.2.0
./system/org/ops4j/pax/logging/pax-logging-log4j2/2.2.0/pax-logging-log4j2-2.2.0.jar
./system/org/ops4j/pax/logging/pax-logging-api
./system/org/ops4j/pax/logging/pax-logging-api/2.2.0
./system/org/ops4j/pax/logging/pax-logging-api/2.2.0/pax-logging-api-2.2.0.jar
./system/org/ops4j/pax/logging/pax-logging-logback
./system/org/ops4j/pax/logging/pax-logging-logback/2.2.0
./system/org/ops4j/pax/logging/pax-logging-logback/2.2.0/pax-logging-logback-2.2.0.jar
My etc/startup.properties looks good having pax-logging entries:
mvn\:org.ops4j.pax.logging/pax-logging-api/2.2.0 = 8
mvn\:org.ops4j.pax.logging/pax-logging-log4j2/2.2.0 = 8
Also, I checked a compatibility table on pax-logging github page (https://github.com/ops4j/org.ops4j.pax.logging), seems pax-logging 2.2.0 is compatible with log4j2 2.22.1.
I found a similar question on stackoverflow but it didn't help me (karaf / filter:="(&(osgi.wiring.package=org.apache.logging.log4j)(version>=2.17.0)).
Did I miss anything else?
I found a solution but it's quite strange, if anyone can explain, it would be good.
Pax-logging 2.2.0 which is native for Karaf 4.4.3 exports org.slf4j v1.8 in its MANIFEST; however, log4j2 2.22.1 requires [2.0.0; 3.0.0) as mentioned in the Karaf log. It looks like log4j2 2.22.1 is not compatible with pax-logging 2.2.0 but github pax-logging page says it should be. I updated pax-logging from 2.2.0 to 2.2.6 which exports org.slf4j 2.0.6 and I can start Karaf. Probably, it would be better to downgrade log4j2.