aspose file tools*
The moose likes Servlets and the fly likes Class.forName return null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Class.forName return null" Watch "Class.forName return null" New topic
Author

Class.forName return null

age spets
Ranch Hand

Joined: Aug 07, 2002
Posts: 68
Class.forName("com.ibm.as400.access.AS400JDBCDriver") return with null.
Get this exception:
java.lang.ClassNotFoundException: sun.com.ibm.as400.access.AS400JDBCDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:257)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:134)
at dbaseMail.connect(dbaseMail.java:40)
at MailClientMass.DBConnect30(MailClientMass.java:204)
at MailClientMass.hentEmail(MailClientMass.java:163)
at MailClientMass.main(MailClientMass.java:247)
Anyone that can help me solve this problem?
Ken Robinson
Ranch Hand

Joined: Jul 25, 2002
Posts: 52
Most likely the class you are attempting to load is not in your CLASSPATH.
age spets
Ranch Hand

Joined: Aug 07, 2002
Posts: 68
Is using websphere application developer. The Jar file that include the driver is in the classpath and also in the properties. The weird thing is that other classes in the same project find the driver. Other solutions?
Ken Robinson
Ranch Hand

Joined: Jul 25, 2002
Posts: 52
The fact that you are getting a ClassNotFound exception all but guarentees this is a Classpath problem.
Although you may be able to compile the code, the runtime envionment may be configured differently.
Is this a web app or standalone? The type of app and where you deploy/run has a big effect on what classes are available.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
To see the classpath that your servlet is actually running under, use System.getProperty("java.class.path"). As Ken suggests, you may find your runtime configuration isn't what you think it is.


"I'm not back." - Bill Harding, Twister
sdsharma
Greenhorn

Joined: Sep 18, 2002
Posts: 1
Try importing the following:
import java.lang.Runtime;
import java.sql.*;
import oracle.jdbc.driver.*;
You may go two routes.
Route: 1 - You may put your Driver classes in your Oracle lib and set your classpath like this depending upon your Oracle environment.
D:\Oracle\Ora81\jdbc\lib\816classes12.zip;
Route: 2 - You may put your Driver classes in the lib folder of your App Server and set its classpath.
age spets
Ranch Hand

Joined: Aug 07, 2002
Posts: 68
Thx for the help. It was not in my classpath. This was easy to see when I used the code:
System.out.println(System.getProperty("java.class.path"));
Good tips!
thx all.
Age
Tracey Currier
Ranch Hand

Joined: Feb 06, 2001
Posts: 50
Thank you, this helped me, too.
Using 1.3.1 on IPlanet looking
for a jconnect driver (JDBC driver)


MS,MS,SCJP,SCBCD Seize the day!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class.forName return null