jakartaee / rest

Jakarta RESTful Web Services
Other
361 stars 117 forks source link

Handler dispatch failed: java.lang.VerifyError: Bad type on operand stack #1153

Closed bencoepp closed 1 year ago

bencoepp commented 1 year ago

Hi, trying to implement via Maven but get this quite bissare error when trying to init the Class. The Solutions provided by the Readme.md were not helpful.

pom.xml

<dependency>
    <groupId>org.gitlab4j</groupId>
    <artifactId>gitlab4j-api</artifactId>
    <version>5.2.0</version>
</dependency>
<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>3.1.2</version>
</dependency>

Implementation

try (GitLabApi gitLabApi = new GitLabApi("https://SOMEURL", "TOKEN")) {
    org.gitlab4j.api.models.Project projectSpec = new org.gitlab4j.api.models.Project()
            .withName(project.getTitle())
            .withDescription(project.getDescription())
            .withIssuesEnabled(false)
            .withMergeRequestsEnabled(true)
            .withWikiEnabled(false)
            .withSnippetsEnabled(true)
            .withPublic(true);

    org.gitlab4j.api.models.Project newProject = gitLabApi.getProjectApi().createProject(projectSpec);
}

Error Output

[dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: 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:
    0000000: bb01 8059 b701 822a b400 58b6 0183 4c2b
    0000010: 1297 b601 8757 2b12 9db6 0187 572a b401
    0000020: 8c99 0013 2b2a b401 90b6 0194 2ab4 0198
    0000030: b601 9c57 2a2b b601 a0b5 00a1 2ab4 00a1
    0000040: b0                                     
  Stackmap Table:
    append_frame(@52,Object[#392])
] 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:
    0000000: bb01 8059 b701 822a b400 58b6 0183 4c2b
    0000010: 1297 b601 8757 2b12 9db6 0187 572a b401
    0000020: 8c99 0013 2b2a b401 90b6 0194 2ab4 0198
    0000030: b601 9c57 2a2b b601 a0b5 00a1 2ab4 00a1
    0000040: b0                                     
  Stackmap Table:
    append_frame(@52,Object[#392])

    at org.gitlab4j.api.GitLabApi.<init>(GitLabApi.java:444) ~[gitlab4j-api-5.2.0.jar:na]
    at org.gitlab4j.api.GitLabApi.<init>(GitLabApi.java:366) ~[gitlab4j-api-5.2.0.jar:na]
    at org.gitlab4j.api.GitLabApi.<init>(GitLabApi.java:132) ~[gitlab4j-api-5.2.0.jar:na]

I hope that someone might be able to answer my question what exactly I did wrong here. Thank you all for your attention.

jansupol commented 1 year ago

Hi @BenCoepp, You are mixing Jersey 3.1 (EE10) which requires Jakarta REST 3.1 API with very old 2.0.1 API (from EE 7). Note that the maven artifact changed from javax.ws.rs to jakarta.ws.rs.

If you have any further issues, please file the issue on the Jersey project not here. This is the API project that deals with the issues in the API and the Spec.