简体   繁体   English

JSP异常-找不到类(tomcat)

[英]JSP exception - class not found (tomcat)

I'm setting up an existing application on a new Tomcat 5.5 server connecting to a Postgres database (running on Debian Lenny). 我正在连接到Postgres数据库(在Debian Lenny上运行)的新Tomcat 5.5服务器上设置现有应用程序。 When I access it I get a series of stack traces with the following root cause: 当我访问它时,我得到了一系列具有以下根本原因的堆栈跟踪:

java.lang.ClassNotFoundException: java.sql.SQLClientInfoException
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1363)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1209)
    java.lang.Class.forName(libgcj.so.90)
    java.lang.Class.initializeClass(libgcj.so.90)
    java.lang.Class.initializeClass(libgcj.so.90)
    org.postgresql.Driver.makeConnection(Driver.java:382)
    org.postgresql.Driver.connect(Driver.java:260)
    java.sql.DriverManager.getConnection(libgcj.so.90)
    jof.DBConnection.getConnection(DBConnection.java:81)
    jof.BeanInterfaceBase.db(BeanInterfaceBase.java:263)
    jof.BeanInterfaceBase.getStatement(BeanInterfaceBase.java:613)
    jof.HelpInterface.findByNaturalId(HelpInterface.java:81)
    jof.HelpInterface.findByNaturalId(HelpInterface.java:128)
    org.apache.jsp.index_jsp.getHelp(index_jsp.java:162)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:369)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    java.lang.reflect.Method.invoke(libgcj.so.90)
    org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
    java.security.AccessController.doPrivileged(libgcj.so.90)
    javax.security.auth.Subject.doAsPrivileged(libgcj.so.90)
    org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
    org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)

What's missing? 缺少了什么?

 java.lang.ClassNotFoundException: java.sql.SQLClientInfoException 

What's missing? 缺少了什么?

To be precise: the mentioned class is missing in the runtime classpath. 准确地说:运行时类路径中缺少提到的类。 It must be in the runtime classpath as a standalone class file ( *.class ) or packaged in a JAR file ( *.jar ). 它必须在运行时类路径中作为独立的类文件( *.class )或打包在JAR文件中( *.jar )。 Alternatively you can also add its actual path to the runtime classpath. 或者,您也可以将其实际路径添加到运行时类路径。

By default the webapp's Webapp/WEB-INF/lib and Webapp/WEB-INF/classes folders are covered by the runtime classpath, as is appserver's Appserver/lib folder and the Java's JRE/lib . 默认情况下,运行时类路径覆盖了webapp的Webapp/WEB-INF/libWebapp/WEB-INF/classes文件夹,以及appserver的Appserver/lib文件夹和Java的JRE/lib

Any 3rd party webapp-specific JAR files ought to be placed in Webapp/WEB-INF/lib . 任何第三方特定于Webapp/WEB-INF/lib JAR文件都应放置在Webapp/WEB-INF/lib Any webapp-specific classes (servlets, etc..) ought to be placed in Webapp/WEB-INF/classes . 任何特定于Webapp/WEB-INF/classes类(servlet等)都应放在Webapp/WEB-INF/classes Any appserver-specific (or webapp-common) JAR files ought to be placed in Appserver/lib . 任何特定于应用程序服务器(或webapp通用)的JAR文件都应放置在Appserver/lib The Java's JRE/lib folder must be left untouched. 必须保留Java的JRE/lib文件夹。

Hope this helps. 希望这可以帮助。

Edit : the actual problem is worse: this is indeed a Java 6 only class. 编辑 :实际问题更糟:这确实是Java 6唯一的类。 Tomcat is apparently running on a Java 5. Review your JAVA_HOME environment variable. Tomcat显然在Java 5上运行。查看您的JAVA_HOME环境变量。 It must at least point to root installation folder of Java 6 JRE. 它必须至少指向Java 6 JRE的根安装文件夹。

This is a guess, but I see that java.sql.SQLClientInfoException is a class that was introduced in Java6. 这是一个猜测,但是我看到java.sql.SQLClientInfoException是Java6中引入的类。 What version of Java is being used to launch your Tomcat server? 哪个Java版本用于启动Tomcat服务器? Maybe you are developing under Java6 but then deploying to a Tomcat running Java5? 也许您是在Java6下开发的,然后部署到运行Java5的Tomcat?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM