This discussion is archived
13 Replies Latest reply: Apr 9, 2013 9:58 AM by jschellSomeoneStoleMyAlias RSS

JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..

1001448 Newbie
Currently Being Moderated
JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
I am getting below error when i m trying to access oracle db using oracle 11g client. It works with earlier oracle client versions. how do i resolve this. is there any issue with version of ojdbc6.jar that i am using??? I cant use thin driver since its an old application for which i dont have source files.

Apr 6, 2013 1:00:59 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:262)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:346)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at PettyCash.SysDate.getSysSubSys(SysDate.java:232)
at org.apache.jsp.PettyCash.index_jsp._jspService(org.apache.jsp.PettyCash.index_jsp:186)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Code is as follow for reference

import oracle.jdbc.driver.*;

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection ("jdbc:oracle:oci8:@" + database,db_user, db_pass);


eNVIRONMENT VARIABLES set are as follows:
classpath
C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\lib\classes12.jar;C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\lib\ojdbc6.jar;

JAVA_HOME
C:\Program Files\Java\jdk1.5.0_04

PATH
C:\Program Files\Java\jdk1.5.0_04\bin

ORACLE_HOME
D:\Oracle11\product\11.2.0\client_1\BIN
  • 1. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    gimbal2 Guru
    Currently Being Moderated
    Java classpath hell debugging 101: copy paste the error you get ("java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path") into google and benefit from the fact that dozens or even hundreds of people have had this problem before you.
  • 2. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    1001448 Newbie
    Currently Being Moderated
    tried it.....didnt get poper links..
  • 3. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    rp0428 Guru
    Currently Being Moderated
    >
    It works with earlier oracle client versions. how do i resolve this. is there any issue with version of ojdbc6.jar that i am using???
    >
    No - the issue is with the ojdbc6.jar that you ARE NOT using.
    >
    classpath
    C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\lib\classes12.jar;C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\lib\ojdbc6.jar;
    >
    Do you see that 'classes12.jar' in the classpath BEFORE the ojdbc6.jar at the END?

    You can't mix and match JDBC jar files. Get rid of the classes12.jar file altogether.
    >
    I cant use thin driver since its an old application for which i dont have source files.
    >
    Really? Then how can you use ANY driver if you don't have the source files?
  • 4. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    1001448 Newbie
    Currently Being Moderated
    thanks buddy.....ok...will try 2 put ojdbc6.jar before 'classes12.jar.. if that doesnt work will remove classes12.jar from path....will post d result tomorow..i hope it works....thanks again.

    Edited by: 998445 on Apr 6, 2013 11:20 PM
  • 5. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    1001448 Newbie
    Currently Being Moderated
    now getting a different error
    Apr 8, 2013 10:58:10 AM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1650)

    ENVIROMENT VARIABLES SET
    USER VARIABLES
    CLASSPATH
    classpath%;C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;D:\Oracle11\product\11.2.0\client_1\jdbc\lib\ojdbc6.jar;

    PATH
    C:\Program Files\Java\jdk1.5.0_04\bin

    SYSTEM VARIABLES
    JAVA_HOME
    C:\Program Files\Java\jdk1.5.0_04
    PATH
    D:\Oracle11\product\11.2.0\client_1\BIN
    ORACLE HOME
    D:\Oracle11\product\11.2.0\client_1\BIN

    what am i doing wrong???..
  • 6. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    gimbal2 Guru
    Currently Being Moderated
    Yeah ojdbc6 is for Java 6. If you're using Java 5 you need ojdbc5. The download page already tells you that you know.
  • 7. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    1001448 Newbie
    Currently Being Moderated
    tried with ojdbc5 also ...........still getting the same error. plz help..
  • 8. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    1001448 Newbie
    Currently Being Moderated
    Apr 8, 2013 5:24:06 PM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.NullPointerException
         at org.apache.jsp.abc.index_jsp._jspService(org.apache.jsp.abc.index_jsp:280)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
         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:868)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
         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)
  • 9. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    gimbal2 Guru
    Currently Being Moderated
    Exercise for you: locate some sort of "work" directory in your server's installation directory and in that work directory find the org.apache.jsp.abc.index_jsp.java source file the stack trace is referring to; then check line 280 of that file to figure out what exactly is null. Basic exception debugging stuff this.

    And that org.apache.jsp.abc.index_jsp.java source file is the servlet that was generated based on a JSP you are trying to run, just in case you didn't know that happened.
  • 10. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    1001448 Newbie
    Currently Being Moderated
    that's the problem...i dont have the source code of that files just class files..........can you please check whether below envt variables set are correct or not??????
    ENVIROMENT VARIABLES SET
    USER VARIABLES
    CLASSPATH
    classpath%;C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;D:\Oracle11\product\11.2.0\client_1\jdbc\lib\ojdbc6.jar;

    PATH
    C:\Program Files\Java\jdk1.5.0_04\bin

    SYSTEM VARIABLES
    JAVA_HOME
    C:\Program Files\Java\jdk1.5.0_04
    PATH
    D:\Oracle11\product\11.2.0\client_1\BIN
    ORACLE HOME
    D:\Oracle11\product\11.2.0\client_1\BIN
  • 11. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    rp0428 Guru
    Currently Being Moderated
    >
    java.lang.UnsupportedClassVersionError: Bad version number in .class file
    >
    That means the version of Java runtime you are using is trying to load classfiles compiled for a LATER version of Java.

    The class files have 'version' info embedded in them that tells the version of Java that the class file was compiled for. That 'version' is different for 1.4x versions and earlier, 1.5 and 1.6.
    >
    Java 1.6x -> Version 50.0
    Java 1.5x -> Version 49.0
    Java 1.4x -> Version 48.0
    >
    So Java 1.5x can NOT load or run class files compiled for version 1.6x and so on.
    >
    that's the problem...i dont have the source code of that files just class files
    >
    And those class files will have a specific Java 'version' that they were compiled for. You will need to use a Java version that can load and run class files with that version. Later versions of Java can work with the older class versions but older versions of Java can NOT work with newer versions.

    If your class files were compiled for Java 1.6x you can NOT load/run them with Java 1.5x.

    You can use 1.6x to compile your own classes but you will to use the '-target' parameter and specify '1.5' as the version to compile for.
    >
    ..........can you please check whether below envt variables set are correct or not??????
    ENVIROMENT VARIABLES SET
    USER VARIABLES
    CLASSPATH
    classpath%;C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;D:\Oracle11\product\11.2.0\client_1\jdbc\lib\ojdbc6.jar;
    >
    No - when you use an environment variable you need to add the '%' character on BOTH sides.

    You can see if vars are set properly by opening a command window and issuing 'SET' to see what they are.
  • 12. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    Tolls Journeyer
    Currently Being Moderated
    I could well be wrong here (it happens), but doesn't Tomcat use its own classpath?
    I'm pretty sure it doesn't use the one you might have defined under environment variables.
  • 13. Re: JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    Tolls wrote:
    I could well be wrong here (it happens), but doesn't Tomcat use its own classpath?
    I'm pretty sure it doesn't use the one you might have defined under environment variables.
    Correct.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points