Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
28,717 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 1500 total points
ID: 12013634
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
ID: 12022884
0
 

Author Comment

by:eduardotorres17
ID: 12026986
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
ID: 20621146
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

963 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