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 doesn't work on the docker #410

Closed
nodece opened this issue Apr 7, 2024 · 4 comments
Closed

slf4j doesn't work on the docker #410

nodece opened this issue Apr 7, 2024 · 4 comments
Assignees

Comments

@nodece
Copy link

nodece commented Apr 7, 2024

Right now, I'm working on the Apache Pulsar project, and migrating the slf4j to 2.0.12 from 1.7.36, but it always prints the following log:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

please see apache/pulsar#22391, the GHA env is Ubuntu, we are using the testcontainers to run the integration test, and the test image is based on the alpine 3.9:

  • When running this image on ubuntu, it always prints the above log.
  • When running this image on the MacOS, it works fine.

I'm not sure where the problem is, thanks for your time!

How to reproduce

docker run -it nodece/java-test-image bin/pulsar proxy
  • Ubuntu 22
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2024-04-07T14:35:25,623Z [jdk.internal.loader.ClassLoaders$AppClassLoader@63c12fb0] error Uncaught exception in thread main: java.lang.IllegalArgumentException: metadataStoreUrl must be provided
org.apache.pulsar.broker.PulsarServerException: java.lang.IllegalArgumentException: metadataStoreUrl must be provided
        at org.apache.pulsar.proxy.server.ProxyServiceStarter.<init>(ProxyServiceStarter.java:205)
        at org.apache.pulsar.proxy.server.ProxyServiceStarter.main(ProxyServiceStarter.java:215)
Caused by: java.lang.IllegalArgumentException: metadataStoreUrl must be provided
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143)
        at org.apache.pulsar.proxy.server.ProxyServiceStarter.<init>(ProxyServiceStarter.java:193)
        ... 1 more
  • MacOS 14.1.1, it works fine.
2024-04-07T14:46:00,668+0000 [main] ERROR org.apache.pulsar.proxy.server.ProxyServiceStarter - Failed to start pulsar proxy service. error msg metadataStoreUrl must be provided
java.lang.IllegalArgumentException: metadataStoreUrl must be provided
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143) ~[com.google.guava-guava-32.1.2-jre.jar:?]
	at org.apache.pulsar.proxy.server.ProxyServiceStarter.<init>(ProxyServiceStarter.java:193) [org.apache.pulsar-pulsar-proxy-3.3.0-SNAPSHOT.jar:3.3.0-SNAPSHOT]
	at org.apache.pulsar.proxy.server.ProxyServiceStarter.main(ProxyServiceStarter.java:215) [org.apache.pulsar-pulsar-proxy-3.3.0-SNAPSHOT.jar:3.3.0-SNAPSHOT]
2024-04-07T14:46:00,699Z [jdk.internal.loader.ClassLoaders$AppClassLoader@63c12fb0] error Uncaught exception in thread main: java.lang.IllegalArgumentException: metadataStoreUrl must be provided
org.apache.pulsar.broker.PulsarServerException: java.lang.IllegalArgumentException: metadataStoreUrl must be provided
	at org.apache.pulsar.proxy.server.ProxyServiceStarter.<init>(ProxyServiceStarter.java:205)
	at org.apache.pulsar.proxy.server.ProxyServiceStarter.main(ProxyServiceStarter.java:215)
Caused by: java.lang.IllegalArgumentException: metadataStoreUrl must be provided
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143)
	at org.apache.pulsar.proxy.server.ProxyServiceStarter.<init>(ProxyServiceStarter.java:193)
	... 1 more
@ceki
Copy link
Member

ceki commented Apr 7, 2024

@nodece Please refer to https://www.slf4j.org/codes.html#StaticLoggerBinder

The first phrase is quite relevant:

This warning message is reported by slf4j-api version 1.7.x and earlier when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory.

and also

If you are seeing this message, then you are NOT using slf4j-api version 2.0 or later but slf4j-api version 1.7.x or earlier.

In any case, this looks like a packaging issue and not an SLF4J issue.

@ceki ceki added the NOT_A_BUG label Apr 7, 2024
@ceki ceki self-assigned this Apr 7, 2024
@nodece
Copy link
Author

nodece commented Apr 8, 2024

From the logs, it does seem like what you said, I know this log looks like we are using the slf4j2-api 1.7.x or earlier, I ensure the lib includes slf4j2-api 2.0.12, not 1.7.x.

I'm using the same image running on a different OS, it has a different log, how to explain this behavior?

In the MacOS, which prints 2024-04-07T14:46:00,668+0000 [main] ERROR org.apache.pulsar.proxy.server.ProxyServiceStarter - Failed to start pulsar proxy service. error msg metadataStoreUrl must be provided, it works fine.

In the Ubuntu, Failed to start pulsar proxy service wasn't printed.

@nodece
Copy link
Author

nodece commented Apr 8, 2024

Add -verbose:class to the java command, and you can find where slf4j2 loads from.

There are some strange differences in the jars loaded on different platforms.

Thanks.

@nodece nodece closed this as completed Apr 8, 2024
@ceki
Copy link
Member

ceki commented Apr 8, 2024

From the logs, it does seem like what you said, I know this log looks like we are using the slf4j2-api 1.7.x or earlier, I ensure the lib includes slf4j2-api 2.0.12, not 1.7.x.

It does not seem, it is that you are using slf4j 1.7 or earlier.

I'm using the same image running on a different OS, it has a different log, how to explain this behavior?

You have a copy of slf4j-api version 1.7 somewhere else on you class path. As slf4j developers, we cannot investigate issues specific to your environment.

@ceki ceki reopened this Apr 8, 2024
@ceki ceki closed this as completed Apr 8, 2024
@qos-ch qos-ch locked as off-topic and limited conversation to collaborators Apr 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants