gpt4 book ai didi

java - 请求 REST 在 tomcat 上失败

转载 作者:行者123 更新时间:2023-11-28 22:10:41 25 4
gpt4 key购买 nike

SEVERE: Allocate exception for servlet Jersey-Servlet
java.lang.ArrayIndexOutOfBoundsException: 9578
at org.objectweb.asm.ClassReader.readClass(ClassReader.java:2015)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:469)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:425)
at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener.process(AnnotationAcceptingListener.java:169)
at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:883)
at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:840)
at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:755)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1171)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1144)
at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1140)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:299)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1230)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1174)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:847)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

下面是我用来测试的服务。

@Path("/ping")
public class PingService {
@GET
public String respondOK() {
return "SERVICE OK";
}
}

我在尝试执行请求时遇到异常。使用 javax.ws.rs-api:2.0、org.glassfish.jersey.core:jersey-server:2.5、Java-8

最佳答案

问题的原因可能是您使用的是 Tomcat 7。您应该使用最新版本的 Tomcat 8 甚至 Tomcat 9。

当您将 Lambda 表达式或较新的 Java 字节码与版本太旧的 asm.jar 一起使用时,似乎会发生异常。

在这里您可以找到有关该问题的更多详细信息:

关于java - 请求 REST 在 tomcat 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50644828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com