facebook

ClassNotFoundException when attempting to load Oracle Driver

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #230849 Reply

    jedavie
    Member

    Hi,

    I’m experiencing the following error when I try to launch a servlet that attempts a connection to an Oracle 10G db.

    Connecting to the database: jdbc:oracle:thin:@yorkshire:1521:asdb
    User id: items
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at DBServlet1.init(DBServlet1.java:168)……..

    Under the Eclipse Database Explorer, I added the Oracle Thin Driver as explained in the Help Manual(added extra classpath), and it shows a blue check mark beside it (so I assume it can now be found).

    I can also connect manually to the database using trhe Eclipse Database Connection perspective.

    The version of Eclipse I’m using is 3.0.2 and I am also using version 3.8.4 of the MyEclipse plugin.

    It seems that Eclipse still can’t find the OracleDriver but I don’t know why. Any ideas on where I might look next?

    Thanks In Advance,
    Jim Davies

    #230896 Reply

    Riyad Kalla
    Member

    Jim,
    You have setup everything correctly *inside* of MyEclipse, but when you launch your app server, that is launched externally to MyEclipse to keep the runtime environment as “pure” as possible. What that means is that you likely need to navigate to Window > Preferences > MyEclipse > Application Servers > (Name of your app server) > Paths, and then click the “Add” button for the part “Append to classpath” and go ahead and add your JDBC drivers to the classpath for your app server, that way when you try and connect from your code, your app server will be able to find and load the driver.

    #235224 Reply

    sixel
    Member

    Hi,

    I’m having the very opposite problem.

    Oracle Thin Driver is added under Eclipse Database Explorer, the location of the driver has been appended to the classpath, and basically all works very fine when Tomcat is launched through MyEclipse.

    The problem I’m facing is that this doesn’t work when I launch Tomcat externally, it returns :

    
     FATAL - JDBC Driver class not found: oracle.jdbc.driver.OracleDriver
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
        at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
        at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1607)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1089)
    

    I’m running Eclipse 3.1, ME 4.0M3 and Tomcat 5.5.

    I know this has more to be with Tomcat configuration, and this forum is not the best place to ask this question, but if anyone ever faced this problem, and could tell me what stupid thing I might have missed or mis-configured…

    Regards,
    Alexis

    #235227 Reply

    Riyad Kalla
    Member

    Alexis,
    You need your JDBC driver to be present in your <tomcat>\common\lib directory so the server can find it.

    #235266 Reply

    sixel
    Member

    Thanks for the help!

    Actually, the driver (in my case the file classes12.zip) was already in TOMCAT_HOME/common/lib, but it had to be renamed to classes12.jar

    Note that earlier I generated such a file from the unzipped data, and placed it under TOMCAT_HOME/common/lib, and still it didn’t work. Renaming the zip file into a ar file looks like the proper thing to do.

    Thanks for all,
    Alexis

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: ClassNotFoundException when attempting to load Oracle Driver

You must be logged in to post in the forum log in