Solved

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

Posted on 2004-09-08
4
28,608 Views
Last Modified: 2013-12-10
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.
0
Comment
Question by:eduardotorres17
4 Comments
 
LVL 3

Accepted Solution

by:
yuvalg earned 500 total points
Comment Utility
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
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
Comment Utility
0
 

Author Comment

by:eduardotorres17
Comment Utility
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
 
LVL 1

Expert Comment

by:madhuthetom
Comment Utility
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Java TXT, RTF, DOC, DOCX to PDF converter 3 340
Java Uncaught Exception 5 228
Java Email Transport Not working 14 93
Question to Java runtime 10 121
Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now