Link to home
Start Free TrialLog in
Avatar of act1ve
act1ve

asked on

jbuilder to tomcat error

Hi,

I created a simple jsp page with Jbuilder to pull info from a oracle db. It worked perfect within Jbuilder when i ran it. However im struggling to get this over to the folder where i have tomcat installed to run it outside of jbuilder.

I copied the folder which was created by Jbuilder, namely, "JSPTest" into my webapps folder. However i'm getting erros when i try and run JSPTest.jsp saying:

exception

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.


An error occurred between lines: 35 and 73 in the jsp file: /momentum/JSPTest/defaultroot/JSPTest.jsp

Generated servlet error:
G:\Apache Tomcat 4.0\work\Standalone\localhost\_\momentum\JSPTest\defaultroot\JSPTest$jsp.java:80: Class oracle.jdbc.driver.OracleDriver not found.
                      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                                                                         ^


An error occurred between lines: 81 and 175 in the jsp file: /momentum/JSPTest/defaultroot/JSPTest.jsp

Generated servlet error:
G:\Apache Tomcat 4.0\work\Standalone\localhost\_\momentum\JSPTest\defaultroot\JSPTest$jsp.java:151: Class org.apache.jsp.IOException not found.
                    catch (IOException ioe) {


This works perfectly in Jbuilder though.

I have oracle drivers in web-inf/lib.

In jbuilder i added the drivers by doing the following:

Select Project->Default Project Properties.

Click the "Required Libraries" tab in the center of the dialog window, and click "Add".

Click "New" to add a new library. You should see the New Library Wizard. Give the new library a name like "Oracle JDBC Driver".

Click the "Add" button and click in the directory chooser until you've selected classes111.zip in the directory where you installed it or found it. Be sure to select the file itself, not the directory it's in. Click "OK" to select the file.

I can't understand why it will run in jbuilder but then not on its own in tomcat?

Avatar of act1ve
act1ve

ASKER

i just tried another piece of code, not created with jbuilder and i get the following error:

Could not find the database driver Giving up...connection is null

Looks like it cant find db driver for some reason:

this is my code i tried

<%@ page import="java.sql.*" %>
<%
    Connection connection = null;
    try {
        // Load the JDBC driver
        String driverName = "oracle.jdbc.OracleDriver";
        Class.forName(driverName);
   
        // Create a connection to the database
        String serverName = "server";
        String portNumber = "1521";
        String sid = "orawit";
        String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
        String username = "username";
        String password = "password";
        connection = DriverManager.getConnection(url, username, password);
    } catch (ClassNotFoundException e) {
        out.println( "Could not find the database driver");
    } catch (SQLException e) {
      e.printStackTrace();
        out.println( "Could not connect to the database");
    }

 if( connection == null )
 {
    out.println( "Giving up...connection is null" ) ;
 }
 else
 {
    try {
        // Create a result set containing all data from my_table
        Statement stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM Supervisor");
      while( rs.next() )
      {
            out.println( rs.getString( 1 ) + "<BR>" );
      }
       } catch (SQLException e) {
       }
 }
%>

i definatly have classes111.zip in WEB-INF\lib though

ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of act1ve

ASKER

same error unfortunaetly :(

my path to classes111.zip is now Apache Tomcat 4.0\common\lib

i'm not too sure what could be wrong here, thanks for your help

Avatar of act1ve

ASKER

hey mate, what i did was rename the zip to .jar, i think per as your suggestion in a previous question i made

the full path i have to it now is:

Apache Tomcat 4.0\webapps\ROOT\WEB-INF\lib

then classes.jar,

its connecting ok now!

thanks for your help
Sweet! glad it worked...:-)