java.lang.AbstractMethodError : I get this exception when I am trying to initiate an outbound voice call using nexmo(vonage) API

标签 java spring-mvc nexmo abstractmethoderror

我所有相关依赖项的 pom.xml。没有其他依赖项在内部使用以下依赖项。

<dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.9.9</version>
    </dependency>
<dependency>
      <groupId>com.sparkjava</groupId>
      <artifactId>spark-core</artifactId>
      <version>2.6.0</version>
    </dependency>
    <dependency>
      <groupId>com.vonage</groupId>
      <artifactId>client</artifactId>
      <version>6.0.0</version>
    </dependency>

    <dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt-api</artifactId>
      <version>0.11.0</version>
    </dependency>
    <dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt-impl</artifactId>
      <version>0.11.0</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt-jackson</artifactId>
      <version>0.11.0</version>
      <scope>runtime</scope>
    </dependency>
<dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt</artifactId>
      <version>0.9.1</version>
    </dependency>
使用 vonage SDK 发起出站语音调用的 Java 代码。
VonageClient client = VonageClient.builder().applicationId(APPLICATION_ID).privateKeyContents(PRIVATE_KEY).build();
    
Ncco ncco = new Ncco(TalkAction.builder(MESSAGE).voiceName(VOICE_TYPE).build());
CallEvent callEvent=client.getVoiceClient().createCall(newCall(TO_NUMBER,FROM_NUMBER, ncco));
执行代码时抛出异常。

java.lang.AbstractMethodError: Receiver class io.jsonwebtoken.impl.DefaultJwtBuilder does not define or inherit an implementation of the resolved method 'abstract io.jsonwebtoken.JwtBuilder signWith(java.security.Key, io.jsonwebtoken.SignatureAlgorithm)' of interface io.jsonwebtoken.JwtBuilder. at com.nexmo.jwt.JwtGenerator.generate(JwtGenerator.kt:49) ~[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.vonage.client.auth.JWTAuthMethod.apply(JWTAuthMethod.java:43) ~[client-6.0.0.jar:6.0.0] at com.vonage.client.AbstractMethod.applyAuth(AbstractMethod.java:127) ~[client-6.0.0.jar:6.0.0] at com.vonage.client.AbstractMethod.execute(AbstractMethod.java:73) ~[client-6.0.0.jar:6.0.0] at com.vonage.client.voice.CallsEndpoint.post(CallsEndpoint.java:57) ~[client-6.0.0.jar:6.0.0] at com.vonage.client.voice.VoiceClient.createCall(VoiceClient.java:61) ~[client-6.0.0.jar:6.0.0] at com.senpiper.core.listener.VoiceCallListener.listen(VoiceCallListener.java:37) ~[classes/:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]

最佳答案

问题是引用:

<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt</artifactId>
    <version>0.9.1</version>        
</dependency>
删除此依赖项将解决您的问题。这个包被前面的三个包取代,它们是同一个包的模块化版本,参见 v0.10.0 release notes for details您的 POM 文件中的以下内容就足够了:
<dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt-api</artifactId>
      <version>0.11.0</version>
</dependency>
<dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt-impl</artifactId>
      <version>0.11.0</version>
      <scope>runtime</scope>
</dependency>
<dependency>
      <groupId>io.jsonwebtoken</groupId>
      <artifactId>jjwt-jackson</artifactId>
      <version>0.11.0</version>
      <scope>runtime</scope>
</dependency>
Vonage SDK 依赖于 jjwt v0.10.5,但您的应用程序阻塞的方法是在 v0.10.0 中引入的。 - 当争论被翻转时。 Maven 在处理依赖项的副本时可能有点古怪。在这种情况下,因为您正在引用 0.9.1jjwt显然它正在引入一个不兼容的版本。如果我必须在黑暗中拍摄,我猜是对非模块化 jjwt 的引用。包在其他依赖项之前 - 这就是为什么它被拉入而不是其他依赖项。
无论如何 - 只需删除旧的引用 jjwt包 - 这将解决您的问题。

关于java.lang.AbstractMethodError : I get this exception when I am trying to initiate an outbound voice call using nexmo(vonage) API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66221676/

相关文章:

grails - 连接SMS插件时出现Grails错误

SMS包含某些运营商未提供的链接

java - 为什么编译器会在多行中输出单个警告?

spring - 如何使用 spring security 和 Thymeleaf 获取当前登录用户的 ID

java - 为什么 Spring 优先处理 405 Http Error 而不是 406 Http Error

java - @EnableWebSecurity 和 @EnableWebMvcSecurity 有什么区别?

android - nexmo和Google登录之间的冲突

java - Struts2注解@RequestParameter

java - 使用 jackson JsonNodeFactory 的最佳方式

java - 数字 .access$XXXX 代表什么?