Jersey REST Exception java.lang.ArrayIndexOutOfBoundsException at org.objectweb.asm.ClassReader.readInt

StackOverflow https://stackoverflow.com/questions/20096883

  •  03-08-2022
  •  | 
  •  

Question

I am using Jersey 1.2 for building RESTful services using JDK1.5

When I test REST services, I am getting the following exception.

java.lang.ArrayIndexOutOfBoundsException: 2884779 at org.objectweb.asm.ClassReader.readInt(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess (AnnotationScannerListener.java:130) at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner$1. f(FileSchemeScanner.java:83) at com.sun.jersey.core.util.Closing.f(Closing.java:68)

I have created a simple class for testing

@Path("/employee")
public class TestRest {


    @GET
    @Produces( { MediaType.TEXT_HTML })
    public String getClichedMessage() {

        return "Hello Smith";
    }
}

How can I resolve this issue?

My jar versions

jersey-server-1.2.jar
jersey-core-1.2.jar
grizzly-servlet-webserver-1.9.18-i.jar
asm-3.1.jar
jsr311-api-1.1.jar
Was it helpful?

Solution

check your annotation

  @POST
  @Produces(MediaType.TEXT_HTML) also try

Also try

you are having an incorrect version of asm.jar on your classpath. Make sure:

your deployed lib folder contains the same jars as target/app.war/WEB-INF/lib

you don't have two versions of the asm.jar

you don't have conflicting versions in maven

OTHER TIPS

In my case I had this code

@GET
@Path("/get_something")
@Produces(MediaType.APPLICATION_JSON)
public Message<String> getSomething(@QueryParam("p_item") String p_item,  @QueryParam("p_items") List<String> p_items) throws Exception {
    ...
    p_items.forEach(s -> {
       try {
           // something that throws IOException 
       } catch (IOException e) {
           throw new RuntimeException(e);
       }
    });
    ...
}

After I changed forEach to regular loop it worked.

I was using apache server 8.5.59 and getting same exception. Now I moved to apacher server version 8.5.12.

It is working fine.

Please find jar details

  • asm-3.1.jar
  • jersey-bundle-1.1.5.1.jar

JDK : Zulu 8.36.0.2

Eclipse : Oxygen.2 Release (4.7.2)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top