java.lang.AbstractMethodError 在尝试通过 rabbitMQ 实现 nexmo SDK 的入站调用时发生

java.lang.AbstractMethodError occurs while trying to implement call inbound of nexmo SDK through rabbitMQ

我正在尝试借助 rabbitMQ 将使用 nexmo java SDK 的呼叫入站功能集成到我的 spring MVC 项目中。但我不断收到以下异常

[WARN ] 2021-01-26 14:52:26.913 [org.springframework.amqp.rabbit.config.ListenerContainerFactoryBean#6-9]   ConditionalRejectingErrorHandler - Execution of Rabbit message listener failed.
org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener method 'listen' threw exception
        at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:371) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:292) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1542) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1468) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1456) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:1451) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1400) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:870) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:854) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access00(SimpleMessageListenerContainer.java:78) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.mainLoop(SimpleMessageListenerContainer.java:1137) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1043) [spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]
Caused by: java.lang.AbstractMethodError: io.jsonwebtoken.impl.DefaultJwtBuilder.addClaims(Ljava/util/Map;)Lio/jsonwebtoken/JwtBuilder;
        at com.nexmo.jwt.JwtGenerator.generate(JwtGenerator.kt:44) ~[jwt-1.0.1.jar:?]
        at com.nexmo.jwt.Jwt.generate(Jwt.kt:44) ~[jwt-1.0.1.jar:?]
        at com.nexmo.jwt.Jwt.generate$default(Jwt.kt:43) ~[jwt-1.0.1.jar:?]
        at com.nexmo.jwt.Jwt.generate(Jwt.kt) ~[jwt-1.0.1.jar:?]
        at com.nexmo.client.auth.JWTAuthMethod.apply(JWTAuthMethod.java:49) ~[client-5.6.0.jar:5.6.0]
        at com.nexmo.client.AbstractMethod.applyAuth(AbstractMethod.java:133) ~[client-5.6.0.jar:5.6.0]
        at com.nexmo.client.AbstractMethod.execute(AbstractMethod.java:79) ~[client-5.6.0.jar:5.6.0]
        at com.nexmo.client.voice.CallsEndpoint.post(CallsEndpoint.java:62) ~[client-5.6.0.jar:5.6.0]
        at com.nexmo.client.voice.VoiceClient.createCall(VoiceClient.java:66) ~[client-5.6.0.jar:5.6.0]
        at com.senpiper.core.listener.VoiceCallListener.listen(VoiceCallListener.java:63) ~[classes/:?]
        at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
        at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
        at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:363) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        ... 12 more

RabbitMQ Listener class 实现调用入站逻辑的地方。

@RabbitListener
public class VoiceCallListener {
    public void listen(VoiceCallPojo voiceCallPojo) {
        NexmoClient client = NexmoClient.builder()
                .apiKey(API_KEY)
                .applicationId(APPLICATION_ID)
                .privateKeyContents(PRIVATE_KEY).httpConfig(HttpConfig.defaultConfig())
                .signatureSecret(SECRET_KEY)
                .build();
        Ncco ncco = new Ncco(
         TalkAction.builder(voiceCallPojo.getMessage()).voiceName(VoiceName.ADITI).build()
        );
        CallEvent result = client.getVoiceClient().createCall(new Call(voiceCallPojo.getCallNumber(),FROM_NUMBER, ncco));
    }
}

POM 依赖关系

<dependency>
      <groupId>com.nexmo</groupId>
      <artifactId>client</artifactId>
      <version>5.6.0</version>
    </dependency>
    <dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt-impl</artifactId>
      <version>0.11.2</version>
      <scope>runtime</scope>
    </dependency>

这与spring-兔子无关;这是您正在使用的两个库版本之间的不兼容,并且在从您的任何代码调用时都会发生。请参阅 AbstractMethodError.

的 javadoc
/**
 * Thrown when an application tries to call an abstract method.
 * Normally, this error is caught by the compiler; this error can
 * only occur at run time if the definition of some class has
 * incompatibly changed since the currently executing method was last
 * compiled.
 *
 * @author  unascribed
 * @since   1.0
 */

您需要找出兼容的版本。