Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AbstractMethodError when try to initialize Spring

I'm developing an application with Spring, vaadin and maven like tool di project managment. Now when try to execute jetty:run i get the following error:

java.lang.AbstractMethodError: org.slf4j.impl.Log4jLoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:159)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)

This is my pom.xml

  <!-- Logging dependencies   -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>com.springsource.org.apache.commons.logging</artifactId>
        <version>1.1.1</version>
    </dependency>


    <!-- Log4J dependencies -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>com.springsource.slf4j.log4j</artifactId>
        <version>1.5.6</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>com.springsource.slf4j.api</artifactId>
        <version>1.5.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.log4j</groupId>
        <artifactId>com.springsource.org.apache.log4j</artifactId>
        <version>1.2.15</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-ext</artifactId>
        <version>1.7.1</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.1</version>
        <scope>runtime</scope>
    </dependency>

     <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
         <exclusions>
        <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
        <version>${spring.version}</version>
    </dependency>

How can do to solve this problem?

like image 1000
Skizzo Avatar asked Sep 22 '26 06:09

Skizzo


2 Answers

I solved commenting this two dependencies:

     <!-- Log4J dependencies 
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>com.springsource.slf4j.log4j</artifactId>
        <version>${slf4j.log4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>com.springsource.slf4j.api</artifactId>
        <version>${slf4j.log4j.api.version}</version>
    </dependency>
    -->
like image 106
Skizzo Avatar answered Sep 24 '26 19:09

Skizzo


There is conflict with the logging dependency that you have managed. Replace your dependency with below: This will resolve your dependency issue

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.6.1</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.26</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>0.9.26</version>
        </dependency>
like image 40
dhamibirendra Avatar answered Sep 24 '26 20:09

dhamibirendra