gpt4 book ai didi

java - Tomcat 内部错误

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

我有一个 AuthorizationServlet,它在用户单击登录页面中的按钮时被调用。这是servlet的doPost方法的一段代码:

        AuthorizationBean bean = new AuthorizationBean();
String login = (String) request.getSession().getAttribute("login");
String password = (String) request.getSession().getAttribute("password");
try {
UserType type = bean.getRoleOfUser(login, password);
switch(type) {
...
}
} catch (DaoException ex) {
throw new ServletException(ex.getMessage());
}

我省略了一些代码,因为它不适用问题。实际上,DaoException 只能在这一行抛出 UserType type = bean.getRoleOfUser(login, password);在方法 getRoleOfUser 中,我使用 tomcat 的连接池连接到数据库(我如何获得连接的描述在第一篇文章中 here )

这里还有我的 context.xml,它创建了数据库连接的资源:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/Project">
<Resource name="jdbc/Project" auth="Container"
type="javax.sql.DataSource" maxActive="100"
maxIdle="30" maxWait="10000"
username="name"
password="password"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:XE"/>
</Context>

当调用 AuthorizationServlet 时,出现这样的错误:

javax.servlet.ServletException: Error instantiating servlet class com.tspp.common.AuthorizationServlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
java.lang.Thread.run(Thread.java:662)
root cause

java.lang.NoClassDefFoundError: com/tspp/dao/exceptions/DaoException
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
java.lang.Class.getConstructor0(Class.java:2699)
java.lang.Class.newInstance0(Class.java:326)
java.lang.Class.newInstance(Class.java:308)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
java.lang.Thread.run(Thread.java:662)
root cause

java.lang.ClassNotFoundException: com.tspp.dao.exceptions.DaoException
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
java.lang.Class.getConstructor0(Class.java:2699)
java.lang.Class.newInstance0(Class.java:326)
java.lang.Class.newInstance(Class.java:308)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
java.lang.Thread.run(Thread.java:662)

我试过调试它,但调试器甚至没有到达 servlet doPost 方法。实际上,当我启动程序时(在 servlet 激活之前)抛出了最后 2 个异常

我该如何解决这个问题?

最佳答案

确保所有类都在 WEB-INF/classes

关于java - Tomcat 内部错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6331879/

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