Suresh Rajagopal
Suresh Rajagopal

Reputation: 183

Storm Topology not submit due to multiple log4j files

Storm Topology submit is failing due to multiple log4j error.

In local eclipse, it working. But when submit the topology in Storm cluster, topology submission is failing.

I am using Storm version 1.1.1 & kafka_2.9.2 (0.8.1.1). How do I find log4j files coming from jars through maven in eclipse?

         <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <artifactId>log4j-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                 <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>logback-classic</groupId>
                    <artifactId>ch.qos.logback</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
     <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.9.2</artifactId>
        <version>0.8.1.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
            </exclusion>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Error log:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/apache-storm-1.0.1/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/apps/project/demo/app/demo-app.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.apache.logging.log4j.core.lookup.MapLookup.newMap(I)Ljava/util/HashMap; from class org.apache.logging.log4j.core.lookup.MainMapLookup
        at org.apache.logging.log4j.core.lookup.MainMapLookup.<clinit>(MainMapLookup.java:37)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:185)
        at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:65)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
        at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
        at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
        at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
        at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
        at org.apache.log4j.Category.<init>(Category.java:56)
        at org.apache.log4j.Logger.<init>(Logger.java:35)
        at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
        at org.apache.log4j.Logger.getLogger(Logger.java:39)
        at org.apache.log4j.Logger.getLogger(Logger.java:43)
        at com.demo.apps.my.topology.BaseTopology.<clinit>(BaseTopology.java:19)

Upvotes: 0

Views: 287

Answers (1)

Suresh Rajagopal
Suresh Rajagopal

Reputation: 183

In eclipse, in Dependency Hierarchy view, filtered log4j, slf4j jars.

Observed that some other dependent jars also has log4j slf4j jars.

After excluded all duplicate jars, rebuilt the application.

Now no duplicate jars found and able to submit topology.

So check Maven Dependency Hierarchy view and remove duplicate jars.

Upvotes: -1

Related Questions