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

[Bug]: class org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.apache.logging.slf4j.SLF4JLoggerContext and org.apache.logging.log4j.core.LoggerContext are in unnamed module of loader 'app') #33983

Open
2 of 17 tasks
pavanarya-equifax opened this issue Feb 13, 2025 · 1 comment

Comments

@pavanarya-equifax
Copy link

pavanarya-equifax commented Feb 13, 2025

What happened?

Hi I am trying to make use of log4j and I see that Dataflow (Apache beam already includes Slf4j)
So after upgrading from 2.51.0 of Apache Beam, I am facing issues with logs

Dependencies in my pom.xml related to Log4j and Slf4j

<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.16</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.24.3</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.24.3</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.24.3</version>
        </dependency>

I am getting following exception

java.lang.ClassCastException: class org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.apache.logging.slf4j.SLF4JLoggerContext and org.apache.logging.log4j.core.LoggerContext are in unnamed module of loader 'app')

Note: I am seeing this error after an upgrade from Apache Beam 2.51.0 to above versions
Also this is occurring in Dataflow env and not with direct runner

Command I use for pushing code to Dataflow

mvn -s $MAVEN_SETTINGS compile exec:java \
                                            -Dexec.cleanupDaemonThreads=false \
                                            -Dexec.mainClass=${mainClass} \
                                            -Dexec.args=" \
                                                --runner=${apacheBeamRunner} \
                                                --project=${project_id} \
                                                --templateLocation=${templateLocation} \
                                                --tempLocation=${tempLocation} \
                                                --region=${region}"

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam YAML
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Infrastructure
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Samza Runner
  • Component: Twister2 Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner
@liferoad
Copy link
Contributor

cc @shunping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants