当前位置: 技术问答>java相关
找不到类的错误
来源: 互联网 发布时间:2015-06-07
本文导语: type Exception report message Internal Server Error description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Unable to compile class for JS...
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 11 in the jsp file: /xlt/login_confirm.jsp
Generated servlet error:
G:JBuilder6jakarta-tomcat-4.0.1worklocalhost_xltlogin_0005fconfirm$jsp.java:73: Class mydb.mydb not found.
mydb.mydb LoginBean = null;
^
An error occurred at line: 11 in the jsp file: /xlt/login_confirm.jsp
Generated servlet error:
G:JBuilder6jakarta-tomcat-4.0.1worklocalhost_xltlogin_0005fconfirm$jsp.java:76: Class mydb.mydb not found.
LoginBean= (mydb.mydb)
^
An error occurred at line: 11 in the jsp file: /xlt/login_confirm.jsp
Generated servlet error:
G:JBuilder6jakarta-tomcat-4.0.1worklocalhost_xltlogin_0005fconfirm$jsp.java:81: Class mydb.mydb not found.
LoginBean = (mydb.mydb) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "mydb.mydb");
^
Note: G:JBuilder6jakarta-tomcat-4.0.1worklocalhost_xltlogin_0005fconfirm$jsp.java uses or overrides a deprecated API. Recompile with "-deprecation" for details.
3 errors, 1 warning
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:189)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
登录时发生以上错误,说是类找不到?
附代码:
mydb.java
package mydb;
import java.sql.*;
public class mydb {
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:sunshine";
private Connection conn = null;
private Statement stmt = null;
ResultSet rs = null;
public mydb() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("mydb(): " + e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
public void executeUpdate(String sql) {
stmt = null;
rs=null;
try {
conn = DriverManager.getConnection(sConnStr);
stmt = conn.createStatement();
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}
public void closeStmt(){
try{
stmt.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
public void closeConn(){
try{
conn.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
}
-------------------------------------------------------------------------
login_confirm.jsp
登录检查
window.location="passthrough.jsp?showword=登录"
请指教
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 11 in the jsp file: /xlt/login_confirm.jsp
Generated servlet error:
G:JBuilder6jakarta-tomcat-4.0.1worklocalhost_xltlogin_0005fconfirm$jsp.java:73: Class mydb.mydb not found.
mydb.mydb LoginBean = null;
^
An error occurred at line: 11 in the jsp file: /xlt/login_confirm.jsp
Generated servlet error:
G:JBuilder6jakarta-tomcat-4.0.1worklocalhost_xltlogin_0005fconfirm$jsp.java:76: Class mydb.mydb not found.
LoginBean= (mydb.mydb)
^
An error occurred at line: 11 in the jsp file: /xlt/login_confirm.jsp
Generated servlet error:
G:JBuilder6jakarta-tomcat-4.0.1worklocalhost_xltlogin_0005fconfirm$jsp.java:81: Class mydb.mydb not found.
LoginBean = (mydb.mydb) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "mydb.mydb");
^
Note: G:JBuilder6jakarta-tomcat-4.0.1worklocalhost_xltlogin_0005fconfirm$jsp.java uses or overrides a deprecated API. Recompile with "-deprecation" for details.
3 errors, 1 warning
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:189)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
登录时发生以上错误,说是类找不到?
附代码:
mydb.java
package mydb;
import java.sql.*;
public class mydb {
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:sunshine";
private Connection conn = null;
private Statement stmt = null;
ResultSet rs = null;
public mydb() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("mydb(): " + e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
public void executeUpdate(String sql) {
stmt = null;
rs=null;
try {
conn = DriverManager.getConnection(sConnStr);
stmt = conn.createStatement();
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}
public void closeStmt(){
try{
stmt.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
public void closeConn(){
try{
conn.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
}
-------------------------------------------------------------------------
login_confirm.jsp
登录检查
window.location="passthrough.jsp?showword=登录"
请指教
|
在classes目录下应该有mydb目录,然后才是mydb.class文件
classesmydbmydb.class
classesmydbmydb.class
|
当然不对,在 mydb这个类中,有package mydb这句话吧,哪也就是说mydb.class在mydb这个包中,在文件系统中,就是把mydb.class这个文件也得放到mydb这个目录下去,要不然系统找mydb这个类时,他先找到mydb这个包所在的位置,试问你只将mydb.class这个文件放到ROOTWEB-INFclasses下,你让系统how to find the package mydb?
|
在这里面加一个
再试一下
|
要将类放ROOTWEB-INFclasses目录中
|
你的程序编译通过了吗?
|
你是将mydb这个目录都放到ROOTWEB-INFclasses下,还是只将mydb.class这个文件放到ROOTWEB-INFclasses下,我感觉你是后者,这样出的问题
|
有可能!