3

我正在使用 Jersey 1.2 使用 JDK1.5 构建 RESTful 服务

当我测试 REST 服务时,我收到以下异常。

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) 在 com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner$1。f(FileSchemeScanner.java:83) 在 com.sun.jersey.core.util.Closing.f(Closing.java:68)

我创建了一个简单的测试类

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


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

        return "Hello Smith";
    }
}

我该如何解决这个问题?

我的 jar 版本

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
4

3 回答 3

2

检查您的注释

  @POST
  @Produces(MediaType.TEXT_HTML) also try

也试试

您的类路径中的 asm.jar 版本不正确。确保:

您部署的 lib 文件夹包含与 target/app.war/WEB-INF/lib 相同的 jar

你没有两个版本的 asm.jar

你在 Maven 中没有冲突的版本

于 2013-11-20T13:18:27.313 回答
1

我正在使用 apache server 8.5.59 并得到同样的异常。现在我搬到了 apacher 服务器版本 8.5.12。

它工作正常。

请查找罐子详细信息

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

JDK:祖鲁 8.36.0.2

Eclipse:Oxygen.2 版本 (4.7.2)

于 2021-03-18T10:47:52.633 回答
0

就我而言,我有这个代码

@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);
       }
    });
    ...
}

在我更改forEach为常规循环后,它起作用了。

于 2020-06-26T10:58:37.470 回答