Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error instantiating class file

Status
Not open for further replies.

newbiepg

Programmer
Nov 6, 2002
181
IN
I have created a java class file in a folder in WEB-INF/classes/myproject

I am getting this error when I call it from a jsp file

root cause

java.lang.InstantiationException: class myproject.Validate : java.lang.InstantiationException: myproject.Validate
at org.apache.jsp.index$jsp._jspService(index$jsp.java:113)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
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)


This line is causing the error(in the jsp file)

<jsp:useBean id=&quot;myOb&quot; class=&quot;myproject.Validate&quot; />

This is the code for the class file



ackage myproject;

import java.util.HashSet;
import java.util.Set;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.*;
import java.sql.*;
import java.io.Serializable;

public class Validate implements java.io.Serializable
{
public static final String SQL_SELECT = &quot;select m_users.id, m_users.name, m_users.level_no from m_users. where m_users.id=? and m_users.password=?&quot;;
private Connection cnn;
public int user_ID;
public int levelId;
public String chkUsr,chkPass;

public Validate( Connection cnn )
{
if ( cnn == null ) throw new IllegalArgumentException( &quot;Connection object is null&quot; );

this.cnn = cnn;
}

public void checkUser(String usr, String passwd)
{
PreparedStatement stmt;

ResultSet rs;
chkUsr = usr;
chkPass = passwd;

if(chkUsr.length() >0 && chkUsr != null && chkPass.length() > 0 && chkPass != null)
{
try
{
stmt = cnn.prepareStatement(SQL_SELECT ,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);
stmt.setString(1,chkUsr);
stmt.setString(2,chkPass);
rs = stmt.executeQuery();

if(rs != null)
{
while(rs.next())
{
user_ID = rs.getInt(&quot;usr_id&quot;);

}
rs.close();
}
if(stmt != null)
{
stmt.close();
}
}

catch(SQLException sql)
{
System.out.println( sql);
}

}
}

public int ifValidUser()
{
System.out.println(user_ID);
return user_ID;

}
}


I am new in using beans , I got the same error in another place, I could do with some help in instantiating class files in tomcat.

I am using redhat linux 9.0, Postgresql 7.3 and Tomcat 4.16

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top