Monday, May 17, 2010

Load Oracle OCI driver on GlassFish (linux)

I had a really hard time finding the way to load the Oracle native libraries (Oracle runtime 10gR2 installation) on GlassFish (2.1.1) in linux (CentOS 5.4). Apparently GlassFish ignores the famous LD_LIBRARY_PATH variable for unknown reasons. I even tried setting it at the system wide profile. Nothing worked.

The java error was :
java.lang.UnsatisfiedLinkError: no ocijdbc10 in java.library.path

I wrote a small java class that loaded the oci driver successfully. I was sure the parameters were correct. GlassFish still ignored them. I realised that GlassFish was the problem. I tried setting -Djava.library.path. It still didn't work.

To make a long story short the answer is to set it at the GlassFish Admin GUI :
Configuration -->
server-config -->
JVM-settings -->
Tab: Path Settings -->
Native Library Path Prefix : /path/to/oracle/client/installation/lib

I hope this will save you the time I spent searching fruitlessly the internet.
Cheers

P.S.
Do not forget to give the Oracle native libraries the rx permissions to the FlassFish Admin user!

2 comments:

  1. Having the same problem. Been working on it for days, hope this helps...

    ReplyDelete
  2. I couldn't get the full oci url working:
    jdbc:oracle:oci:@// [host] : [port] / [service name]

    So I have been using the thin driver as follows:
    jdbc:oracle:thin:@ [host] : [port] / [service name]

    ReplyDelete