Reasons for getting "java.lang.UnsatisfiedLinkError: no ocijdbc8 in java.library.path" when accessing an Oracle DB with Connection con = myDriver.connect(connectionURL, props);

Gentlemen,
                after doing a full install of an oracle client and setting all possible libraries in the classpath

set CLASSPATH=%CLASSPATH%;%ORACLE_HOME%\classes111.jar;%ORACLE_HOME%\classes111_g.jar;
set CLASSPATH=%CLASSPATH%;%ORACLE_HOME%\classes12.jar;%ORACLE_HOME%\classes12_g.jar;
set CLASSPATH=%CLASSPATH%;%ORACLE_HOME%\classes12dms.jar;%ORACLE_HOME%\classes12dms_g.jar;
set CLASSPATH=%CLASSPATH%;%ORACLE_HOME%\ojdbc14.jar;%ORACLE_HOME%\ojdbc14_g.jar;%ORACLE_HOME%\ocrs12.jar;
set CLASSPATH=%CLASSPATH%;%ORACLE_HOME%\nls_charset11.jar;%ORACLE_HOME%\nls_charset12.jar;

where ORACLE_HOME was set as an environment variable in my pc: ORACLE_HOME = C:\oracle\ora92\jdbc\lib,

I am trying to access an Oracle db with this code in an ejb:

Connection con = null;
try{
Properties props = new Properties();
      props.put("user","BizAgiVision");
      props.put("password", "BizAgi");
      props.put("DatabaseName", "BizAgiVision");
      props.put("dll", "ocijdbc8");
      props.put("protocol", "oci8");
      
      Driver myDriver = (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
      String connectionURL = "jdbc:oracle:oci8:@(description=(address=(host=devt_oracle)(protocol=tcp)(port=1521))(connect_data=(SID=BizAgiOr)))";
                con =    myDriver.connect(connectionURL, props);

...code Continues..

When running this, I get the exception message

      

java.rmi.RemoteException: EJB Exception: ; nested exception is:
        java.lang.UnsatisfiedLinkError: no ocijdbc8 in java.library.path

Start server side stack trace:
java.rmi.RemoteException: EJB Exception: ; nested exception is:
        java.lang.UnsatisfiedLinkError: no ocijdbc8 in java.library.path
        at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteException(EJBRunti
meUtils.java:100)
        at weblogic.ejb20.internal.BaseEJBHome.handleSystemException(BaseEJBHome
.java:309)
        at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:2
42)
        at com.testing.session.stateless.FundsManagerStatelessSession_qoqat1_EOI
mpl.addFunds(FundsManagerStatelessSession_qoqat1_EOImpl.java:107)
        at com.testing.session.stateless.FundsManagerStatelessSession_qoqat1_EOI
mpl_WLSkel.invoke(Unknown Source)
        at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
        at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:114)
        at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
        at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:785)
        at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:308)
        at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:30)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
Caused by: java.lang.UnsatisfiedLinkError: no ocijdbc8 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1491)
        at java.lang.Runtime.loadLibrary0(Runtime.java:788)
        at java.lang.System.loadLibrary(System.java:834)
        at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:228)
        at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:246)

        at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:365)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
        at com.testing.session.stateless.FundsManagerStatelessBean.addFunds(Fund
sManagerStatelessBean.java:98)

THE QUESTION IS, DO I HAVE AN ERROR IN THE URL STRING OR THE PROPERTIES OBJECT?
I am sure I have included all the needed .jars in the CLASSPATH.

THANKS.
eduardotorres17Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
yuvalgConnect With a Mentor Commented:
It seems like you are trying to use Oracle OCI driver.
In this case you are using both jars and some native library files.
You have to update your LD_LIBRARY_PATH to point to your oracle client lib directory, you can also do it by setting this path with -Djava.library.path .

Goodluck,
Yuval.
0
 
sompol_kiatkamolchaiCommented:
0
 
eduardotorres17Author Commented:
Gentlemen,

I added the path for ocijdbc9.dll in the Weblogic PATH, and now

I am getting a SQL Exception when trying to obtain a jdbc connection using the JDBC libraries of the OCI9 Oracle client.

Since I am using the C:\j2sdk1.4.2_03 SDK in Weblogic(JAVA_HOME value), I included this in my Weblogic classpath:

set CLASSPATH=%CLASSPATH%;%ORACLE_HOME%\ojdbc14.jar;%ORACLE_HOME%\ojdbc14_g.jar;%ORACLE_HOME%\ocrs12.jar;
set CLASSPATH=%CLASSPATH%;%ORACLE_HOME%\nls_charset12.jar;

where ORACLE_HOME is an environment variable set as c:\oracle\ora92\bin

and in my path (this path contains the ocijdbc9.dll):
set PATH=.;%WL_HOME%\server\bin;%JAVA_HOME%\bin;%PATH%;C:\oracle\ora92\bin;

The JDBC code I am using is

Connection con = null;
     Statement workStmt = null;
 try{
           
      Properties props = new Properties();
     props.put("user","BizAgiVision");
     props.put("password", "BizAgi");
     props.put("dll", "ocijdbc9");
     props.put("protocol", "oci9");
     
     Driver myDriver = (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
     
     DriverManager.registerDriver(myDriver);
     String connectionURL = "jdbc:oracle:oci9:@(description=(address=(host=devt_oracle)(protocol=tcp)(port=1521))(connect_data=(SID=BizAgiOr)))";
     
     con =    DriverManager.getConnection(connectionURL, props);

Now I am getting an exception saying that this URL Connection String is invalid. Do you know what the problem might be with this String?
Do you know any Oracle experts who know the exact rules for these Connection Strings? By the way, this String used to work with Oci8 in a coworker's machine.

SQL exception-->Invalid Oracle URL specified
java.sql.SQLException: Invalid Oracle URL specified
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:182)
        at java.sql.DriverManager.getConnection(DriverManager.java:512)
        at java.sql.DriverManager.getConnection(DriverManager.java:140)
        at com.testing.session.stateless.FundsManagerStatelessBean.addFunds(Fund
sManagerStatelessBean.java:98)
        at com.testing.session.stateless.FundsManagerStatelessSession_qoqat1_EOI
mpl.addFunds(FundsManagerStatelessSession_qoqat1_EOImpl.java:97)
        at com.testing.session.stateless.FundsManagerStatelessSession_qoqat1_EOI
mpl_WLSkel.invoke(Unknown Source)
        at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
        at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:114)
        at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
        at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:785)
        at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:308)

Thanks,
           Eduardo
0
 
madhuthetomCommented:
Here is a sample Connection sting

jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST =(FAILOVER = OFF)(ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.COM)(PORT = 1515)))(CONNECT_DATA = (SID = 123)))

change XXX.XXX.COM to your string.

Easy way is , open the weblogic admin console and choose the driver and test out the connection there itself . You will know if you are using the right kind of driver or not.

http://localhost:<your port no> /console , will show you the weblogic admin console, provided your server is running
0
All Courses

From novice to tech pro — start learning today.