[Solved] Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:

Running error

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.scheduling.quartz.SchedulerAccessor.registerListeners(SchedulerAccessor.java:351)

The following method did not exist:

    org.quartz.Scheduler.getListenerManager()Lorg/quartz/ListenerManager;

The method's class, org.quartz.Scheduler, is available from the following locations:

    jar:file:/D:/repository/org/opensymphony/quartz/quartz/1.6.1/quartz-1.6.1.jar!/org/quartz/Scheduler.class

It was loaded from the following location:

    file:/D:/repository/org/opensymphony/quartz/quartz/1.6.1/quartz-1.6.1.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.quartz.Scheduler

Analysis: it worked well before, but suddenly it didn’t work. Reading the report incorrectly may be caused by the jar package conflict of the scheduled task

1. A global check reveals that shiro-all has introduced this jar package

Solution:

When querying the dependency, I found that it is an optional part of shiro, so I exclude it directly.

<dependency>
    <groupId>org.apache.shiro</groupId>
    <artifactId>shiro-all</artifactId>
    <version>1.4.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-quartz</artifactId>
        </exclusion>
    </exclusions>
</dependency>

If the shiro-all package is introduced in a jar package, the following code can be placed under the parent package introduced by the project

     <exclusions>
        <exclusion>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-quartz</artifactId>
        </exclusion>
    </exclusions>

 

Read More: