I don't think you can load the Oracle native driver more than once (that 
tries to load the native bits/dlls more than once, and that's what the 
"Native Library already loaded" is about).

A couple of choices are to try to use the existing DataSource (which I 
don't think JDBCAppender can do out of the box, though I'd be surprised if 
no one has fixed that), or trying to leave the driverClassName off (if 
possible) so that you rely on the driver that was loaded earlier. (That's 
assuming the log4j appender is the later of the two to load, and that the 
JDBCAppender will let you leave off the "driver" parameter).

Douglas E Wegscheid
Lead Technical Analyst, Whirlpool Corporation


"A wrong note played hesitatingly is a wrong note. A wrong note played 
with conviction is interpretation."



"Exposito Aguilera, Francisco" <francisco.expos...@es.issworld.com> wrote 
on 05/18/2010 08:14:04 AM:

> Hello,
> 
> I have a doubt about how to configure log4j in order to avoid the error 
> 
> java.lang.UnsatisfiedLinkError: Native Library
> C:\oracle\product\10.2.0\client_1\BIN\ocijdbc10.dll already loaded in
> another classloader
> 
> I want log write the log in the same database as the other sql 
statements I
> need for my application.
> 
> 
> I have a DAO Connection class with this method:
> 
> public static Connection getConnection()
> {
>    InitialContext initContext = new InitialContext();
>    Context envContext  = (Context)
> initContext.lookup("java:/comp/env");
>    DataSource dataSource = (DataSource)
> envContext.lookup("jdbc/testdb");
>    return dataSource.getConnection();
> }
> 
> This method uses the DB info placed in META-INF/context.xml file:
> 
> <Resource name="jdbc/testdb" auth="Container"
>            type="javax.sql.DataSource" username="aaaa"
> password="bbbb"
>            driverClassName="oracle.jdbc.driver.OracleDriver"
>            url="jdbc:oracle:oci:@DESARROLLO"
>            maxActive="20" maxIdle="24"/>
> 
> 
> Then I have my log4j.xml files configured like that:
> 
> <appender name="db" class="org.apache.log4j.jdbc.JDBCAppender">  
>    <param name="driver" value="oracle.jdbc.driver.OracleDriver"/> 
>    <param name="URL" value="jdbc:oracle:oci:@DESARROLLO"/>
>    <param name="user" value="aaaa"/> 
>    <param name="password" value="bbbb"/>
>    <param name="sql" value="INSERT INTO TABLE.LOG4JTEST
> (Fecha,Clase,Prioridad,usuario,Mensaje)
>    VALUES ( '%n%d{yyyy-MM-dd
> 
HH:mm:ss}','%C-%M(%L)','%p',SUBSTR('%m',1,INSTR('%m',':')-1),SUBSTR('%m',INS
> TR('%m',':')+2))"/>
>    <param name="sql" value="INSERT INTO FEXPOSITO.LOG4JTEST
> (Fecha,Clase,Prioridad,usuario,Mensaje)
>    VALUES ( '%n%d{yyyy-MM-dd HH:mm:ss}','%C-%M(%L)','%p','%m','%m')"/>
> 
> </appender>
> 
> 
> But when I execute the first log.debug statement (the connection class 
has
> been already executed), I receive the error
> 
> java.lang.UnsatisfiedLinkError: Native Library
> C:\oracle\product\10.2.0\client_1\BIN\ocijdbc10.dll already loaded in
> another classloader
> 
> Any idea?
> 
> Thanks in advance.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 

Reply via email to