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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP Status 500 - Unable to compile class for JSP

Status
Not open for further replies.

nykotai

Programmer
Oct 7, 2003
10
0
0
US
Hi,

I m getting the error org.apache.jasper.JasperException: Unable to compile class for JSP
and at the boot in root cause i get
java.lang.ClassNotFoundException: org.apache.jsp.db_jsp

db.jsp is the jsp file that i m trying to run when i get this error.

Here the content of db.jsp

<html>
<head>
<title>DB Test</title>
</head>
<body>

<%@ page import=&quot;DBTest&quot; %>




<%
foo.DBTest tst = new foo.DBTest();
tst.init();
%>

<h2>Results</h2>
Foo <%= tst.getFoo() %><br/>
Bar <%= tst.getBar() %>

</body>
</html>

It's calling DBTest.java whose content is

package DBTest;

import javax.naming.*;
import javax.sql.*;
import java.sql.*;

public class DBTest {

String foo = &quot;Not Connected&quot;;
int bar = -1;

public void init() {
try{
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception(&quot;Boom - No Context&quot;);

DataSource ds =
(DataSource)ctx.lookup(
&quot;java:comp/env/jdbc/jdbcDBConnection&quot;);

if (ds != null) {
Connection conn = ds.getConnection();

if(conn != null) {
foo = &quot;Got Connection &quot;+conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst =
stmt.executeQuery(
&quot;select id, foo, bar from testdata&quot;);
if(rst.next()) {
foo=rst.getString(2);
bar=rst.getInt(3);
}
conn.close();
}
}
}catch(Exception e) {
e.printStackTrace();
}
}

public String getFoo() { return foo; }
public int getBar() { return bar;}
}


I 've trying pretty much everything that i could find online
concerning this error ... any ideas? Any help will be greatly appreciated...
 
You are getting your packages mixed up. The following lines are conflicting as you say the class &quot;DBTest&quot; is in differering packages ....


Code:
<%@ page import=&quot;DBTest&quot; %>
-- no package name here ...
Code:
foo.DBTest tst = new foo.DBTest();
-- now in package &quot;foo&quot; ...
Code:
package DBTest;

import javax.naming.*;
import javax.sql.*;
import java.sql.*;

public class DBTest {
-- now in package DBTest.

Sort out these inconsistencies and you'll be fine.
 
never mind find the pb...I change package from DBTest to DB and everything worked fine ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top