Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 788
Jacob Avatar asked Nov 06 '25 08:11

Jacob


2 Answers

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

like image 134
constantlearner Avatar answered Nov 08 '25 09:11

constantlearner


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.

like image 35
user435421 Avatar answered Nov 08 '25 09:11

user435421