且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java Servlet中的PostgreSQL连接从数据库中检索信息。得到错误

更新时间:2023-12-04 15:55:46


我得到以下信息错误任何人都知道为什么?

I get the following error any body knows why?

你得到那个错误主体的原因是你的 ClassNotFoundException的处理程序 丢弃原始异常堆栈跟踪。您正在将原始异常的消息写入 System.err ,但(显然)不会进入正常的系统日志。 (您可能会在catalina.out文件中找到该消息...取决于Tomcat的配置/启动方式。)

The reason why you are getting that error body is that your handler for ClassNotFoundException is throwing away the original exception stacktrace. You are writing the original exception's message to System.err but (obviously) that won't go into the normal system logs. (You'll probably find find the message in the "catalina.out" file ... depending on how Tomcat is configured / launched.)

正确的方法这是要么排除异常;例如。

The right way to do this is to either chain the exception; e.g.

    throw new ServletException("Class not found Error", e);

或在您捕获它时明确记录。如果你明确地记录它,请确保记录异常,而不仅仅是异常消息。

or log it explicitly at the point that you catch it. And if you do log it explicitly, make sure that you log the exception, and not just the exception message.

我们除非我们看到原始异常堆栈跟踪,否则无法告诉您问题的实际根本原因...但最可能的两个原因是:

We can't tell you the actual root cause of the problem unless we see the original exception stacktrace ... but the two most likely causes are:


  • 类加载器找不到所需的类;例如因为JAR文件不在正确的位置。

  • 在您尝试加载的类的初始化期间,某些类的类初始化失败。