Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.lang.ClassCastException:java.lang.NoClassDefFoundError

0 views
Skip to first unread message

Patrick Pinchera

unread,
Jul 7, 2000, 3:00:00 AM7/7/00
to
I'm trying to get an applet to run under Netscape Enterprise Server 3.6.
The applet worked fine until I tried to use JDBC to talk to my Informix
database. When the applet tries to connect to the database, I get a
java.lang.ClassCastException:java.lang.NoClassDefFoundError
error. I can get a Java appletthat uses JDBC to connect to the Informix
database successfully, but only when it is run standalone (outside of
NES 3.6). Once I try to run it from the server, I get this error.

I really think it has something to do with the server configuration. I
set my classpath (in config/obj.conf):

classpath="/opt/netscape/suitespot/js/samples:/opt/netscape/suitespot/plugins/java/classes/serv3_0.zip:/opt/netscape/suitespot/plugins/java/local-classes:/opt/netscape/suitespot/plugins/java/classes/servlet3_5.zip:/opt2/informix/ifxjava_home/lib/ifxjdbc.jar"

I had to unzip the files in the ifxjdbc.jar file and put them in
/opt/netscape/suitespot/plugins/java/local-classes to get the
Class.forName(ifxDriver);
to work successfully. Now when the code tries:
conn = (Connection)DriverManager.getConnection(connURL);
I get this java.lang.ClassCastException:java.lang.NoClassDefFoundError
error.

Any pointers you may have would be especially helpful. If there is a
better newsgroup for this question, please let me know. I have searched
a *lot* of newsgroups looking for the problem.

Thanks,
Pat
p...@pinchera.com

Here is the section of code that uses JDBC:

private boolean connectToDBServer( ServletOutputStream out )
throws ServletException, IOException
{
try
{
String ifxDriver = "com.informix.jdbc.IfxDriver";

// Register the INFORMIX-JDBC driver
out.println("Calling Class.forName(" + ifxDriver + ")....<BR>");
Class.forName(ifxDriver);
out.println("Class.forName(" + ifxDriver + ") SUCCESS.<BR>");

out.println("Trying to CONNECT to the database server:<BR>connURL =
'" + connURL + "'<BR>");

// Get a connection to the database server
conn = (Connection)DriverManager.getConnection(connURL);

out.println("Driver loaded...and connection established");
return(true);
}
catch (ClassNotFoundException e)
{
out.println("Could not load the database driver: " +
e.getMessage() + "....<BR>");
out.println("e = " + e + "<BR>");
out.println("e.toString() = " + e.toString() + "<BR>");
return(false);
}
catch (SQLException e)
{
out.println("SQLException caught: " + e.getMessage() + "....<BR>");
return(false);
}
catch (Exception e)
{
out.println("Could not connect to database server....<BR>");
out.println("e.getMessage() = '" + e.getMessage() + "'<BR>");
out.println("e = " + e + "<BR>");
return(false);
}
} // end of connectToDBServer method

And the output is this:

Calling Class.forName(com.informix.jdbc.IfxDriver)....
Class.forName(com.informix.jdbc.IfxDriver) SUCCESS.

Trying to CONNECT to the database server:
connURL =
'jdbc:informix-sqli://www.hostname.com:2055/dbname:INFORMIXSERVER=servername;user=username;password=myPassword'

Could not connect to database server....
e.getMessage() = 'java.lang.NoClassDefFoundError'
e = java.lang.ClassCastException: java.lang.NoClassDefFoundError

Mike Segel

unread,
Jul 9, 2000, 3:00:00 AM7/9/00
to
Just a thought.
Looks like it might be loading the wrong JDBC driver if any.
0 new messages