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,676 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Accepted Solution

by:
yuvalg earned 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

-Xmx and -Xms are the two JVM options often used to tune JVM heap size.   Here are some common mistakes made when using them:   Assume BigApp is a java class file for the below examples. 1.         Missing m, M, g or G at the end …
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

626 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