'Unable to Login to Gitlab through GitlabApi oauth2Login using Java

While trying to connect to Gitlab using below:

GitLabApi.oauth2Login(url,"abc","xyz"); Jar used: org.gitlab4j, version : 4.17.0

It is throwing below Exception:

Feb 18, 2022 11:34:19 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [abcSession] in context with path [] threw exception [Servlet execution threw an exception] with root cause
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/gitlab4j/api/GitLabApiClient.createApiClient()Ljavax/ws/rs/client/Client; @18: invokevirtual
  Reason:
    Type 'org/glassfish/jersey/client/JerseyClientBuilder' (current frame, stack[0]) is not assignable to 'javax/ws/rs/client/ClientBuilder'
  Current Frame:
    bci: @18
    flags: { }
    locals: { 'org/gitlab4j/api/GitLabApiClient', 'org/glassfish/jersey/client/JerseyClientBuilder' }
    stack: { 'org/glassfish/jersey/client/JerseyClientBuilder', 'java/lang/Class' }
  Bytecode:
    0x0000000: bb00 7059 b700 712a b400 19b6 0072 4c2b
    0x0000010: 122c b600 7357 2ab4 0074 9900 132b 2ab4
    0x0000020: 0075 b600 762a b400 77b6 0078 572a 2bb6
    0x0000030: 0079 b500 2f2a b400 2fb0               
  Stackmap Table:
    append_frame(@45,Object[#351])

    at org.gitlab4j.api.GitLabApi.<init>(GitLabApi.java:439)
    at org.gitlab4j.api.GitLabApi.<init>(GitLabApi.java:386)
    at org.gitlab4j.api.GitLabApi.<init>(GitLabApi.java:325)
    at org.gitlab4j.api.GitLabApi.<init>(GitLabApi.java:313)
    at org.gitlab4j.api.GitLabApi.oauth2Login(GitLabApi.java:279)
    at org.gitlab4j.api.GitLabApi.oauth2Login(GitLabApi.java:141)

What could be the reason for this error ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source