Java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
I am trying to connect from a servlet running in Tomcat on my desktop to an instance of Personal Oracle9i running on my desktop. I am gettiung NoClassDefFoundError. The code compiles.
I know it is a path issue but I am at a loss to figure out where. Tomcat does not find the driver however it is in my machines path.
Running following:
j2sdk1.4.1_02
Personal Oracle 9.2
Tomcat 4.1.29
Windows XP
I have added the location of Classes12.zip to the class path: .;c:\Sun\AppServer\lib\j2ee.jar;c:\Sun\AppServer\lib\j2ee-svc.jar;d:\oracle\ora92\jdbc\lib\classes12.zip;
The "root cause" of error is:
java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at OOP.OracleConnectionDemo.doPost(OracleConnectionDemo.java:34)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
The code is as follows:
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import oracle.jdbc.OracleDriver;
//import oracle.jdbc.driver.*; //did not work either
public class OracleConnectionDemo extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException{
Connection con = null;
// Load the Oracle JDBC driver
try{
//two versions did not work
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver);
DriverManager.registerDriver(new OracleDriver());
con = DriverManager.getConnection
("jdbc:oracle:thin:@micron.1521:MCAP","scott","scott");
catch (SQLException e){
catch (Exception e){
finally{
try{
if (con != null)
con.close();
catch(SQLException ignored){
}//finally
}
What you should be realizing is that Tomcat doesn't give a hoot about your system CLASSPATH. It totally ignores it. You really shouldn't even have one, because IDEs and app servers don't even take it into account. Get rid of it.
You're making lots of mistakes here:
(1) The Tomcat docs explicitly state that it won't look inside ZIP files. Change it to a JAR file.
(2) You're using JDK 1.4.1 and classes12.zip? You realize, of course, that there's an ojdbc14.jar available for download from Oracle. Go get it.
(3) Put the JDBC JAR in the WEB-INF/lib directory of your Web app. If you don't have one, you're not deploying your Web app properly.
(4) You've got Java code with empty catch blocks? That's one of the most foolish things a person can do. If an exception's thrown you'll never know it. For goodness sake, at least print the stack trace.
(5) Why do you have those Oracle imports? That ties your code to Oracle. The design of the java.sql package lets you use interfaces. Why don't you write JDBC the way it was meant to be written?
(6) Why aren't you setting up a JNDI data source?
%
Similar Messages
-
Java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
When I run java servlet test_ora.java with IE6.0 I get the following error page:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2349)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:469)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:376)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:518)
at java.lang.Thread.run(Thread.java:536)
root cause
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
at test_ora.doGet(test_ora.java:21)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2349)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:469)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:376)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:518)
at java.lang.Thread.run(Thread.java:536)
Java Web Services Developer Pack/1.0-fcs
I thought it is about JDBC configuration. But when I run JdbcCheckup.java everything works fine. Can anybody help me, please?
test_ora.java looks like this:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class test_ora extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String str_dok_numer, str_f_inkraft;
int int_dok_wal_id;
Connection conn=null;
Statement s = null;
response.setContentType("text/html;charset=iso-8859-2");
PrintWriter out = response.getWriter();
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@192.168.15.2:1521:DB2","janusz","kimono");
s = conn.createStatement();
} catch (SQLException e) {
out.println("Blad polaczenia z baza danych: " + e.getMessage());
try {
ResultSet r =s.executeQuery("select dok_numer, f_inkraft, dok_wal_id from gndlf_umowy_inkraft");
out.println("DOK_NUMER\tF_INKRAFT\tDOK_WAL_ID");
while(r.next()){
out.println (r.getString (1) +"\t" + r.getString (2) + "\t" +r.getString (3));
conn.close();
} catch (Exception e) {
out.println("Wystapil problem z wyslaniem SQL do bazy danych: " + e.getMessage());
finally {
try { conn.close(); }
catch(SQLException e) {}
and here is code for JdbcCheckup.java (I get it from Internet and made some modifications):
* This sample can be used to check the JDBC installation.
* Just run it and provide the connect information. It will select
* "Hello World" from the database.
// You need to import the java.sql package to use JDBC
import java.sql.*;
// We import java.io to be able to read from the command line
import java.io.*;
class JdbcCheckup {
public static void main(String args[])
throws SQLException, IOException
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Prompt the user for connect information
System.out.println("Please enter information to test connection to the database");
String user;
String password;
String database;
user = readEntry("user: ");
int slash_index = user.indexOf('/');
if (slash_index != -1)
password = user.substring(slash_index + 1);
user = user.substring(0, slash_index);
else
password = readEntry("password: ");
database = readEntry("database(a TNSNAME entry): ");
System.out.print("Connecting to the database...");
System.out.flush();
System.out.println("Connecting...");
//Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@" + database, user, password);
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.15.2:1521:" + database, user, password);
System.out.println("connected!!!");
// Create a statement
Statement stmt = conn.createStatement();
// Do the SQL "Hello World" thing
ResultSet rset = stmt.executeQuery("select 'Hello World' from dual");
while (rset.next())
System.out.println(rset.getString(1));
// close the result set, the statement and connect
rset.close();
stmt.close();
conn.close();
System.out.println("Your JDBC installation is correct.");
// Utility function to read a line from standard input
static String readEntry(String prompt)
try
StringBuffer buffer = new StringBuffer();
System.out.print(prompt);
System.out.flush();
int c = System.in.read();
while (c != '\n' && c != -1)
buffer.append((char)c);
c = System.in.read();
return buffer.toString().trim();
catch(IOException e) {
return "";
I use Java Web Service Developer Pack 1.0 on Win98 SE, database Oracle 8.1.7 is installed on dedicated IBM server (AIX 4.x).
I put these lines in autoexec.bat:
set PATH=C:\Perl\bin\;"C:\j2sdk1.4.0\bin";%PATH%
set CLASSPATH=.;C:\j2sdk1.4.0\lib\tools.jar;C:\j2sdk1.4.0\lib\classes12.zip;C:\j2sdk1.4.0\lib\classes111.zip;%CLASSPATH%
set CLASSPATH=C:\jwsdp_1_0\common\lib\servlet.jar;C:\jwsdp_1_0\common\lib\jasper-compiler.jar;C:\jwsdp_1_0\common\lib\jasper-runtime.jar;%CLASSPATH%
set JAVA_HOME=C:\j2sdk1.4.0I have the same problem. I created a JSP page that uses a class to retrieve database information. I added a main method to the class so I would be able to test it. When I test the class using the main method the method returns all the information from the database. When I try it using Tomcat, I get the following error: java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
Does anyone have an idea of what is going on?
My CLASSPATH configuration is the same. -
hi,
I try a simple connect to a DB 9.2.0.1
through JDBC
$javac -d /home/oracle/jdbc Applet1.java
OK
but ...
oracle@pluto:/home/oracle/jdbc$ appletviewer -J-Djava.security.policy=mypolic>
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
at mypackage.Applet1.connectToDB(Applet1.java:55)
at mypackage.Applet1.access$000(Applet1.java:17)
at mypackage.Applet1$1.actionPerformed(Applet1.java:41)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1
64)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstr
ctButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonMode
.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:25
private void connectToDB(ActionEvent e) {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver())
con = DriverManager.getConnection ("jdbc:oracle:thin:@pluto:1521:DB
9IDEV","system","manger");
empValues.setText("Connected to the Database. Fetching Values from
TOTO Tables.\n");
fetchValues();
} catch (SQLException ex) {
System.out.println("Connection Error = " + ex.toString());
I tried with:
CLASSPATH=/tools/oracle/9.2.0/jdbc/lib/classes12.jar
and ( loaded from otn for JDK 1.4 and 9.2.0.1)
CLASSPATH=/tools/oracle/9.2.0/jdbc/lib/ojdbc14.jar
What I have to put in the CLASSPATH, please ???Please don't cross post.
http://forum.java.sun.com/thread.jsp?thread=541572&forum=57&message=2625798
http://forum.java.sun.com/thread.jsp?thread=541573&forum=48&message=2625800
http://forum.java.sun.com/thread.jsp?thread=541574&forum=31&message=2625802 -
I have the following configuration:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
on a Suse 10.1 Linux.
The javaversion is Java.Version = 1.4.2_11
The classpath does look like:
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen> echo $CLASSPATH
/derby.jar:/derbytools.jar:/derbynet.jar:/derbyclient.jar:/derbyTesting.jar:/local/derby/tools/java/jakarta-oro-2.0.8.jar:/derbyLocale_de_DE.jar:/derbyLocale_es.jar:/derbyLocale_fr.jar:/derbyLocale_it.jar:/derbyLocale_ja_JP.jar:/derbyLocale_ko_KR.jar:/derbyLocale_pt_BR.jar:/derbyLocale_zh_CN.jar:/derbyLocale_zh_TW.jar:/oracle/oracle/product/10.2.0/db_1/jdbc/lib/classes12.jar:/oracle/oracle/product/10.2.0/db_1/jdbc/lib/classes12.zip:/oracle/oracle/product/10.2.0/db_1/jlib/orai18n.jar:/oracle/oracle/product/10.2.0/db_1/jdbc/lib/ojdbc14.jar:/home/Eisele/Oracle/ojdbc14.jar:/home/Eisele/FH-Weihenstephan/Winter_Semester_200809/Uebungen
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen>
The Program JDBCVersion.java which I copied out of the Oracle-Documentation looks like:
import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.OracleDataSource;
class JDBCVersion
public static void main (String args[]) throws SQLException
System.out.println("Java.Version = " + System.getProperty("java.version")) ;
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:scott/tiger@host:port:service");
Connection conn = ods.getConnection();
// Create Oracle DatabaseMetaData object
DatabaseMetaData meta = conn.getMetaData();
// gets driver info:
System.out.println("JDBC driver version is " + meta.getDriverVersion());
I get the following error
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen> javac JDBCVersion.java
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen> java -cp ~/FH-Weihenstephan/Winter_Semester_200809/Uebungen/ JDBCVersion
Java.Version = 1.4.2_11
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/pool/OracleDataSource
at JDBCVersion.main(JDBCVersion.java:10)
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen>
Can anyone help me out here and tell me, what I did wrong ?
Thanks in advance !
RüdigerTwo thoughts.
The first is that 10.2.0.1 is unpatched. Why? It has been two years since its release and no one has applied 10.2.0.2, 10.2.0.3 or 10.2.0.4.
The second is that your question is not a database question but a Java question is you are more likely to get an answer that will help you if you post in a group where it is on-topic. -
Java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
Hi everyone,
Can any one plz help me with this problem in connection with the database...im unable to connect from the servlet where my jdbc connectivity code is written when i compile it gives me this error:
Ljava.lang.String;@e53220java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at shoppingcart.shoppingcartservlet.doit(shoppingcartservlet.java:83)
at shoppingcart.shoppingcartservlet.doPost(shoppingcartservlet.java:30)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)Hi
The server is not able to load the jdbc driver path. Place your driver in server classpath
Venkat -
NoClassDefFoundError: oracle/jdbc/OracleDriver
I have a servlet that is supposed to connect to an oracle database select from a table and then return the results. This works in JDeveloper but when I try to deploy it to tomcat I get an error saying the following.
java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at LoginServlet.doPost(LoginServlet.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
How can I resolve this problem ?I have the same problem.
I wrote a simple program as follows.
import java.sql.*;
import oracle.jdbc.*;
import oracle.sql.*;
public class OracleConnect
public static void main (String args []) throws SQLException
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@10.0.0.8:1521:ORCL","scott","tiger");
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT ename FROM emp");
while (rset.next ())
System.out.println (rset.getString (1));
rset.close();
stmt.close();
conn.close();
I am compiling like this.
C;>javac -classpath c:\oracle\ora92\jdbc\lib\classes12.jar;c:\oracle\ora92\jdbc\lib\nls_charset12.jar;. OracleConnect.java
Everything is fine upto now.
But at the time of execution
C:\>java OracleConnect
Java is crying like this.
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDri
ver at OracleConnect.main(OracleConnect.java:11)
Can any one help me to resolve this issue please? By the way, I did not install Jdeveloper. I am using command prompt to do the stuff.
Thanks, -
Hi All,
Getting the above error when running the following export utility:
$ java oracle/apex/APEXExport
ABove error is thrown.
I have looked at most blogs suggested by ML.
Here are my env params:
echo $CLASSPATH
/u01/app/oracle/product/11.2.0/db_1/jdbc/lib/ojdbc5dms.jar
( No, i don't see any classes12.jar. The classes12.zip resides in oui folder. I tried that as well and it didnt work)
echo $JAVA_HOME
/usr/java/jdk1.7.0_02
So for the heck of it, I tried:
$ export CLASSPATH=.:${ORACLE_HOME}/jdbc/lib/classes12.zip
and lo, I am able to at least summon this:
$ java oracle/apex/APEXExport
Usage APEXExport -db -user -password -applicationid -workspaceid -instance -skipExportDate -expSavedReports -debug
-db: Database connect url in JDBC format
-user: Database username
-password : Database password
-applicationid : ID for application to be exported
-workspaceid : Workspace ID for which all applications to be exported
-instance : Export all applications
-skipExportDate : Exclude export date from application export files
-expSavedReports: Export all user saved intera
BUT: when invoking specific job, I get this:
java oracle/apex/APEXExport -db hostname:1521:SID -user apex_030200 -password welcome123 -instance
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at oracle.apex.APEXExport.main(APEXExport.java:315)
any ideas?Hello,
I get a very similar error.
Windows 7 Ultimate SP1
Oracle XE 11.2
Apex 4.1
jdk 6u31-windows x64.exe (installed to C:\Program Files\Java\jdk1.6.0_31\.....)
User Variable CLASSPATH = .\; C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar
User Variable JAVA_HOME = C:\program files\java\jdk1.6.0_31\jre\bin
User Variable ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server
System Variable PATH = C:\oraclexe\app\oracle\product\11.2.0\server\bin;;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\11.0\DLLShared\;C:\Program Files (x86)\Pinnacle\Shared Files\;C:\Program Files (x86)\Pinnacle\Shared Files\Filter\;C:\Program Files (x86)\QuickTime\QTSystem\
At the C:\apex\utilities directory I give the command:
java oracle.apex.APEXExpress -db localhost:1521:XE -user SUSANNA -password skippy123 -expworkspace
I get the error:
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/apex/APEXExpress
Caused by: java.lang.ClassNotFoundException: oracle.apex.APEXExpress
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doProvileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: oracle.apex.APEXExpress. Program will exit. -
Hi
I am trying to use type 4 driver to connect to my Oracle 9i Rel2 database. I downloaded the odbc14.jar from oracle and added in the C:\Oracle9i\jdbc\lib path. As on the website, I setup my environment:
Setting Up Your Environment
On Win95/Win98/NT:
- Add [ORACLE_HOME]\jdbc\lib\classes111.zip and
[ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
(Add classes12.zip and nls_charset12.zip if JDK 1.2.x or 1.3 is
used. Add ojdbc14.jar and nls_charset12.zip if JDK 1.4 is used.)
- Make sure [ORACLE_HOME]\bin is in your PATH.
Still I am getting the following error during runtime:
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at jdbc.InsertQueryEx.main(InsertQueryEx.java:11)
Below is the source code:
import java.sql.*;
import java.io.*;
public class InsertQueryEx {
public static void main(String[] args)throws Exception{
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@Prashy:1521:orcl", "scott", "tiger");
DataInputStream din = new DataInputStream(System.in);
Statement stmt = con.createStatement();
while(true){
try{
System.out.println("enter emp name");
String name = din.readLine();
System.out.println("enter emp no");
int no = Integer.parseInt(din.readLine());
System.out.println("enter emp salary");
float sal = Float.parseFloat(din.readLine());
System.out.println("enter emp address");
String addr = din.readLine();
int count = stmt.executeUpdate("insert into myemp values("+no+",'"+name+"',"+sal+",'"+addr+"')");
if(count>0)
System.out.println("Record added");
else
System.out.println("Failed");
catch (Exception e){
System.err.println("Exception: "+e.getMessage());
Any help is appreciated
Thanks
PrashantI am sorry but I did add those in the classpath but still getting this error:
This is what I have for user variable in classpath:
.;C:\Oracle9i\jdbc\lib\ojdbc14.jar;C:\Oracle9i\jdbc\lib\nls_charset12.jar
error is:
java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at jdbc.InsertQueryEx.main(InsertQueryEx.java:14)
Thanks -
Hi,
I am writing an application and am trying to open a connection to Oracle database that is on a server. I am using the following test code to check if it connects to the database.
import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
String DBurl = "jdbc:oracle:thin:@local:1522:DBORA";
String user = "test";
String pwd = "test123";
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(DBurl, user, pwd);
}On running the above program I keep on getting the following error:
Error : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
java.lang.NullPointerException
If I open the connection using JDeveloper wizard I can see the DB. But if running the above program in the JDev, JCreator or commandline keep on getting the error. Any help is appreciated. ThanksHow do I set the path for the Oracle Driver. ThanksI dunno. You're supposed to know where that class is (what jar it lives in). You set it up in JDeveloper in the first place, so you must have known where it is. After you know that, it's up to you to figure out how JCreator projects are set up to include jars in a project (just like JDeveloper projects do). For the command-line way, you set the classpath on the command-line arguments:
java -cp (your classpath here, which must include the jars it needs) ... -
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/xml/parser/v2/
XSLException
Hi
I have downloaded XDK and was trying to use the XSU feature..
I unzipped the XDK file, I ran the following query on SQL plus
select * from emp. It displayed the full table.
Then i set the class path for XDK,XMLparserv2,oracle JDBC driver and then ran the same query on dos prompt(that is front end command line for java in my case).
The following is the line i tried to execute on the command prompt
java OracleXML getXML -user "scott/tiger" -conn "jdbc:oracle:thin:@localhost
:1521:PomonaT" "select * from emp"
PomonaT is the db name(Host string i use to enter SQL+)
I get the following error
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/xml/parser/v2/
XSLException
at OracleXML.To_XML(OracleXML.java:1038)
at OracleXML.ExecuteGetXML(OracleXML.java:917)
at OracleXML.main(OracleXML.java:184)
IS SOMETHING MISSING IN MY CLASSPATH??
IF YES? Could anyone tell what??
KunalAdd xmlparserv2.jar to Classpath & reboot.
-
Hello All,
I am writing this simple program which connects to Oracle DB ( 10.2 ). The Java version I have is 1.5.0_13 . I do have oracle client installed. When I run the below code ...I get error
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at OraThin.main(OraThin.java:13)The code I have is :
import java.io.*;
import java.sql.*;
public class OraThin {
public static void main(String[] args) {
try {
System.out.println(System.getProperty ("java.class.path") );
Connection con=null;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection(
"jdbc:oracle:thin:@hostname:15282:ServiceName",
"scott",
"tiger");
Statement s=con.createStatement();
s.execute("SELECT SYSDATE FROM DUAL");
s.close();
con.close();
} catch(Exception e){e.printStackTrace();}
} Please suggest as to what am I missing, I am not that well versed with Java.
Thanks in advance,
SamHello Paul,
Thanks for you suggestion. Based on it , I did add the exact jar file in the PATH environmental variable in XP.
Path=C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar;C:\oraclexe\a
pp\oracle\product\10.2.0\server\bin;C:\oracle\product\10.2.0\client_1\bin;C:\Ora
cle\product\10.1.0\Client_1\bin;C:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin\
client;C:\j2sdk1.4.2_06\bin;Even after adding the specific jar file *("C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar")* ..I am getting the exact same error. moreover, to verify this I also tried to import import oracle.jdbc.driver.*.....and now my code would not even complie and I get error *(c:\Program Files\Java\jdk1.5.0_13\bin\OraThin.java:3: package oracle.jdbc.driver*
does not exist ) . I also rebooted my machine just to make sure ...that didnt work either. Also, I changed these jar to be first in the PATH varibale ..to avoid conflict with any later .jar's classes. The code is :
import java.io.*;
import java.sql.*;
import oracle.jdbc.driver.*;
public class OraThin {
public static void main(String[] args) {
try {
System.out.println(System.getProperty ("java.class.path") );
Connection con=null;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection(
"jdbc:oracle:thin:@hostname:15282:ServiceName",
"scott",
"tiger");
Statement s=con.createStatement();
s.execute("SELECT SYSDATE FROM DUAL");
s.close();
con.close();
} catch(Exception e){e.printStackTrace();}
}What am I missing here!! ?
Thanks again,
Sam -
I am evaluating the sun RI of javax.sql package . I downloaded the jdbc_rowset_tiger-1_0_1-mrel-jwsdp.zip package and installed in my machine.
I tried the JdbcRowSet implmenation and it worked pretty smooth. I wanted to try the disconnected Rowset implementation. I tried CachedRowSet Implementation with thin driver. I get the following error message.
Exception in thread "main" java.lang.AbstractMethodError: oracle.jdbc.driver.OracleDatabaseMetaData.locatorsUpdateCopy()Z
at com.sun.rowset.CachedRowSetImpl.execute(Unknown Source)
at com.sun.rowset.CachedRowSetImpl.execute(Unknown Source)
at CachedRowSetSampl.main(CachedRowSetSampl.java:79)
I am using thin driver with Oracle8i db.
Appreciate any early responsesI had the same problem initially.
I fixed it by downloading an updated ojdbc14.jar (1).
It may be because I downloaded the ocrs12.jar from there a bit earlier and the versions of ojdbc14.jar and ocrs12.jar need to match (that is, come from the Oracle10g suite of jars).
Here is the class I used:
import java.sql.*;
import javax.sql.*;
import com.sun.rowset.WebRowSetImpl;
import com.sun.rowset.providers.RIXMLProvider;
public class test {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
WebRowSetImpl wrs = new WebRowSetImpl();
wrs.setCommand("select table_name from user_tables");
wrs.setUsername("scott");
wrs.setPassword("tiger");
wrs.setUrl("jdbc:oracle:thin:@paramount.com:1521:ORCL");
wrs.execute();
wrs.writeXml(System.out);
} catch (Exception e) {
System.out.println("Exception:"+e);
Dale(1) http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc101020.html (Oracle Database 10g JDBC Drivers) -
Tomcat: java.lang.NoClassDefFoundError: oracle/sql/NUMBER
hi,
i have managed to come this far with my "simple" webapplication under tomcat.
the exception is:
java.lang.NoClassDefFoundError: oracle/sql/NUMBER
since i have tried to put the classes12.jar in every reasonable directory without effect, i have to bother this forum. does anyone know "where the dog is burried"(german saying)?
greetz
Selim KeserHi yves,
This class is in the jdev_home/jdbc.lib/ojdbc14.jar.
But prior to deploying your ADF application, did you install the ADF runtime libraries to Tomact as explained here?:
http://www.oracle.com/webapps/online-help/jdeveloper/10.1.3?topic=j2ee_ptomcatdeploy_html
Thanks
Prasanth -
We have recently upgraded all of our servers from:
Java 1.6.31 to 1.6.32
and
Glassfish 3.1.1 to 3.1.2
We upgraded our development server from Oracle 10g to 11g.
Our live servers are working fine. Our development server now is spewing out a java.lang.NoClassDefFoundError: oracle/sql/STRUCT error whenever it encounters a servlet or page which uses this class.
ojdbc14.jar and sdopai.jar were included within the WAR file, and I have tried with them excluded from the WAR file to no avail. We have tried reverting the version of ojdbc.jar on the server to the earlier version, this has made no different.
Any ideas? The full stack trace is below:
[#|2012-05-28T16:15:34.950+0100|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=80;_ThreadName=Thread-2;|StandardWrapperValve[EnterDataSS]: PWC1406: Servlet.service() for servlet EnterDataSS threw exception
java.lang.NoClassDefFoundError: oracle/sql/STRUCT
at oracle.spatial.geometry.JGeometry.load(JGeometry.java:3097)
at Bto.Location.LocatorUtils.JavaScriptifySDO(LocatorUtils.java:97)
at Bto.Chats.Controllers.EnterDataModuleMain.<init>(EnterDataModuleMain.java:136)
at Bto.Chats.SessionBean.initialiseEdm2(SessionBean.java:348)
at Bto.Chats.Servlets.Enter.EnterDataSS.processRequest(EnterDataSS.java:36)
at Bto.Chats.Servlets.ChatsServlet.doGet(ChatsServlet.java:90)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ajp.AjpProcessorTask.invokeAdapter(AjpProcessorTask.java:135)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: oracle.sql.STRUCT
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 33 more
|#]>
Our live servers are working fine. Our development server now is spewing out a java.lang.NoClassDefFoundError: oracle/sql/STRUCT error whenever it encounters a servlet or page which uses this class.
ojdbc14.jar and sdopai.jar were included within the WAR file, and I have tried with them excluded from the WAR file to no avail. We have tried reverting the version of ojdbc.jar on the server to the earlier version, this has made no different.
>
If your code can't find the class then you have the classic NoClassDefFoundError problem you get when any other referenced class can't be located.
The oracle/sql/STRUCT class is in the ojdbc14.jar, ojdbc5.jar and ojdbc6.jar so if it can't be found then that class is missing from the jar you are using (which you can tell by examining the jar contents) or the jar is missing from the classpath being used.
As already mentioned you need the Oracle 11 JDBC files to support Java 1.6
Here is the official Oracle JDBC page that shows the Oracle DB versions supported for each of the JDBC drivers available and also describes the JDBC jars and what JDK versions they support.
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#02_01
>
Which JDBC drivers support which versions of Javasoft's JDK?
pre-8i OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
8.1.5 OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
8.1.6SDK THIN Driver - JDK 1.1.x and JDK 1.2.x (aka Java2)
8.1.6SDK OCI Driver - Only JDK 1.1.x
8.1.6 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
8.1.7 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
9.0.1 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x and JDK 1.3.x
9.2.0 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
10.1.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
10.2.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, JDK 1.4.x, and JDK 5.0.x
11.1.0 OCI and THIN Driver - JDK 1.5.x and JDK 1.6.x
11.2.0 OCI and THIN Driver - JDK 1.5.x and JDK 1.6.x
Please note that JDK 1.4 is not supported by the 11 drivers. -
My compile works just fine: javac mail_create.java
but when I try to run I get OracleDriver error. Not sure how to fix this. Using RedHat Linux 7.3
[ora9ias@tautog classes]$ java mail_create
Error: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriveroracle.j
dbc.driver.OracleDriver
[ora9ias@tautog classes]$ pwd
/home/oracle/9iAS/j2ee/home/default-web-app/WEB-INF/classes
[ora9ias@tautog classes]$
Some of my code...
import java.io.*;
import java.util.*;
import java.text.*;
import java.sql.*;
public class mail_create {
public static void main(String[] arguments) {
StringTokenizer st1;
int cnt1, cnt2, cnt3, cnt4, ival, newal;
String commabv, commemail, comabbrv, commca, commail;
String comcod []=new String [99];
String comvar []=new String [800];
String curabr []=new String [800];
String comail []=new String [800];
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
.....http://search.java.sun.com/search/java/index.jsp?qt=%2Boracledriver+%2Bclassnotfoundexception&nh=10&qp=&rf=1&since=&country=&language=&charset=&variant=&col=javaforums
Maybe you are looking for
-
My I phone 5 will no longer connect to my car via Bluetooth since the 8.1 update?
SInce the 8.1 update my phone will not connect to my Ford car via Bluetooth?
-
Minimize/Maximize a JWindow
Hi everyone, I created an application that derives JWindow instead of the usual JFrame as the parent class of the application. This works fine but I have a following problems listed below that I have not solved yet. 1. Is it possible to implement Max
-
How do I share internet using WRT54G router?
I have a computer that is connected to the internet, and it has 2 Ethernet ports. I'm using 1 of them to connect to the internet, and I want to use my WRT54G router to connect to the internet through the second Ethernet port, for my wireless devices.
-
On my new iMac, mail has no sound after waking from sleep. If I select do not wake for network access in general preferences, the problem does not occur. Anyone have an idea on how to fix this? Thanks --
-
Dear Experts Iam working on a new installed BI Developement server, when i type RRMX it throws me message : BEx analyzer not installed, install BEx Analyzer