dasniko / testcontainers-keycloak

A Testcontainer implementation for Keycloak IAM & SSO.
Apache License 2.0
348 stars 53 forks source link

LogManager error reported during container startup using Keycloak 26.0.1 #164

Open blevine opened 1 week ago

blevine commented 1 week ago

Describe the bug

Just tried moving my environment to Keycloak 26.0.1. Running my integration tests which starts a Keycloak testcontainer I see an ERROR during startup (see logging output). Also note that this error appears to be benign (the testcontainer starts successfully) except that I had to exclude slf4j-jboss-logmanager to see log output from the testcontainer.

<dependency>
  <groupId>org.keycloak</groupId>
  <artifactId>keycloak-services</artifactId>
  <version>${keycloak.version}</version>
  <scope>provided</scope>
  <exclusions>
    <exclusion>
    <groupId>org.jboss.slf4j</groupId>
    <artifactId>slf4j-jboss-logmanager</artifactId>
    </exclusion>
  </exclusions>
</dependency>

This allows my reload4j dependency to work:

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-reload4j</artifactId>
  <version>${slf4j.version}</version>
  <scope>test</scope>
</dependency>

Version

3.4.0

Expected behavior

The testcontainer should start without the ERROR message.

Actual behavior

No response

How to Reproduce?

No response

Relevant log output

Note ERROR at end of logging output

0    [main] INFO  org.testcontainers.images.PullPolicy  - Image pull policy will be performed by: DefaultPullPolicy()
3    [main] INFO  org.testcontainers.utility.ImageNameSubstitutor  - Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
244  [main] INFO  org.testcontainers.dockerclient.DockerClientProviderStrategy  - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
581  [main] INFO  org.testcontainers.dockerclient.DockerClientProviderStrategy  - Found Docker environment with local Unix socket (unix:///var/run/docker.sock)
590  [main] INFO  org.testcontainers.DockerClientFactory  - Docker host IP address is localhost
619  [main] INFO  org.testcontainers.DockerClientFactory  - Connected to docker: 
  Server Version: 27.2.0
  API Version: 1.47
  Operating System: Docker Desktop
  Total Memory: 8932 MB
765  [main] INFO  tc.testcontainers/ryuk:0.7.0  - Creating container for image: testcontainers/ryuk:0.7.0
1024 [main] INFO  tc.testcontainers/ryuk:0.7.0  - Container testcontainers/ryuk:0.7.0 is starting: 7b533cb08119bd68840dc79a91a0d60f3f5ee32b8a9aebd7849940ad3e08a87e
1404 [main] INFO  tc.testcontainers/ryuk:0.7.0  - Container testcontainers/ryuk:0.7.0 started in PT0.638728S
1427 [main] INFO  org.testcontainers.utility.RyukResourceReaper  - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
1428 [main] INFO  org.testcontainers.DockerClientFactory  - Checking the system...
1430 [main] INFO  org.testcontainers.DockerClientFactory  - ✔︎ Docker server version should be at least 1.6.0
1556 [main] INFO  tc.quay.io/keycloak/keycloak:26.0.1  - Creating container for image: quay.io/keycloak/keycloak:26.0.1
1609 [main] INFO  org.testcontainers.utility.RegistryAuthLocator  - Credential helper/store (docker-credential-desktop) does not have credentials for quay.io
1920 [main] INFO  tc.quay.io/keycloak/keycloak:26.0.1  - Container quay.io/keycloak/keycloak:26.0.1 is starting: 282f9ed8e8348aa17e18bd8ec1935f6f46187dc5f9b106fe6feeb2397898bd24
2045 [docker-java-stream-1392774682] INFO  tc.quay.io/keycloak/keycloak:26.0.1  - STDOUT: JAVA_OPTS_KC_HEAP already set in environment; overriding default settings
2064 [main] INFO  org.testcontainers.containers.wait.strategy.HttpWaitStrategy  - /gifted_goldwasser: Waiting for 120 seconds for URL: http://localhost:57077/health/started (where port 57077 maps to container port 9000)
Oct 23, 2024 3:07:19 PM org.jboss.logmanager.JBossLoggerFinder getLogger
ERROR: The LogManager accessed before the "java.util.logging.manager" system property was set to "org.jboss.logmanager.LogManager". Results may be unexpected.

Anything else?

No response

dasniko commented 1 week ago

Thanks for reporting. I already noticed this but haven't found a reliable solution yet.

The problem is, that actually the dependencies in the using project are responsible for this, as they are pulling the slf4j-jboss-logmanager (transitive through keycloak-services) and slf4j-reload4j into the classpath. This is not related to the transitive dependencies of the testcontainers-keycloak lib.

I've not yet a good idea how to solve this and if this is even solvable from this libs side. If you have an idea, it's more than welcome. I think I need some more time to think about it (aside my regular work).

blevine commented 1 week ago

Yes, and as I pointed out it's easily worked around, so not a high priority issue at all. If nothing else, might be worth a mention in the README. Thanks for the quick response!

dasniko commented 1 week ago

Yes, the workaround is easy, but has to be done in the using project. I can mention it in the README, and at the same time I have doubts that this is being read by anybody. 😅