gpt4 book ai didi

java - 泽西 Restful 异常(exception) 1

转载 作者:行者123 更新时间:2023-11-28 23:19:24 29 4
gpt4 key购买 nike

完整存档: google drive

(Tomcat 7.0)

我重复了 Jersey Restful exception 中的代码

本地测试网址 - http://localhost:8080/test/algebra/sum?a=1&b=2

得到了:

HTTP Status 500 - Resource configuration class edu.algebra could not be loaded.

type Exception report

message Resource configuration class edu.algebra could not be loaded.

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Resource configuration class edu.algebra could not be loaded.
org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:466)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:168)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)
root cause

**java.lang.ClassNotFoundException: edu.algebra**
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:264)
org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:407)
org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:397)
java.security.AccessController.doPrivileged(Native Method)
org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:454)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:168)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)

注意 Apache Tomcat/7.0.56 日志中提供了根本原因的完整堆栈跟踪。

为什么?

最佳答案

您的文件夹结构不正确。 Java 代码应该在 src 文件夹中,而不是类中。在“Tomcat 上的 Hello World Web 应用程序”教程中找到一百万个教程并按照它进行操作。例如。 - http://www.srccodes.com/p/article/2/JSP-Hello-World-Program-using-Eclipse-IDE-and-Tomcat-web-server

关于java - 泽西 Restful 异常(exception) 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45629955/

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