Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
位于org.objectweb.asm.ClassReader.readInt的Jersey REST异常java.lang.ArrayIndexOutOfBoundsException_Java_Rest_Jersey_Jdk1.5 - Fatal编程技术网

位于org.objectweb.asm.ClassReader.readInt的Jersey REST异常java.lang.ArrayIndexOutOfBoundsException

位于org.objectweb.asm.ClassReader.readInt的Jersey REST异常java.lang.ArrayIndexOutOfBoundsException,java,rest,jersey,jdk1.5,Java,Rest,Jersey,Jdk1.5,我使用Jersey 1.2使用JDK1.5构建RESTful服务 当我测试REST服务时,我得到以下异常 java.lang.ArrayIndexOutOfBoundsException:2884779位于 org.objectweb.asm.ClassReader.readInt(未知来源)位于 org.objectweb.asm.ClassReader.accept(未知源)位于 org.objectweb.asm.ClassReader.accept(未知源)位于 com.sun.jers

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

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

java.lang.ArrayIndexOutOfBoundsException:2884779位于 org.objectweb.asm.ClassReader.readInt(未知来源)位于 org.objectweb.asm.ClassReader.accept(未知源)位于 org.objectweb.asm.ClassReader.accept(未知源)位于 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
检查您的注释

  @POST
  @Produces(MediaType.TEXT_HTML) also try
也尝试

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

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

您没有两个版本的asm.jar


maven中没有冲突的版本

在我的例子中,我有这个代码

@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);
       }
    });
    ...
}
@GET
@路径(“/get\u something”)
@产生(MediaType.APPLICATION_JSON)
公共消息getSomething(@QueryParam(“p_项”)字符串p_项,@QueryParam(“p_项”)列表p_项)引发异常{
...
p_项目。forEach(s->{
试一试{
//抛出异常的东西
}捕获(IOE异常){
抛出新的运行时异常(e);
}
});
...
}

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

我使用的是ApacheServer8.5.59,并且得到了相同的异常。 现在我转到apacher服务器版本8.5.12

它工作得很好

请查找jar详细信息

  • asm-3.1.jar
  • jersey-bundle-1.1.5.1.jar
JDK:zulu8.36.0.2


Eclipse:Oxygen.2发行版(4.7.2)

你的意思是
MediaType.TEXT\u HTML
,它没有帮助。移除花括号好了,你验证我是否有冲突版本的观点让我想到了冲突的jar,并且有一个spring mvc jar导致了这个问题,尽管我没有在这个项目中使用Maven。我删除了所有不需要的和没有被使用的jar,重新编译了项目并再次测试,它按照预期工作。谢谢你的建议。顺便说一下,
@POST
与ths无关,
@GET
是必需的。为什么是JDK1.5?“这很古老。”LutzHorn对于一个遗留应用服务器,我们有JDK1.5,所以选项有限。