tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Winlöf <winel...@skip.informatik.gu.se>
Subject Tomcat and webapplication-specific java.library.path
Date Fri, 16 Jan 2004 14:48:38 GMT

I have a problem with Tomcat and the java-library.path. 
(My problem isn't Oracle-specific but it is when I use Oracle that problem 
appears since Oracle uses the java.library.path)

What I have managed to do:
Oracle JDBC with works fine if I:
 - put ojdbc14.jar in ${CATALINA_HOME}/common/lib
 - set ORACLE_HOME to the correct directory
 - set LD_LIBRARY_PATH (java.library.path) to include the directory with 
   the needed .so-file

However this is not exactly what I wan't to do. Instead of setting the 
variables in the shell I want to set them from a Java-class when it is 
invoked by Tomcat.

So I set ORACLE_HOME to the same directory as above and include the directory 
with the .so-file in the LD_LIBRARY_PATH by doing this:

System.out.println("JLP  =" + System.getProperty("java.library.path");
System.out.println("OH   =" + System.getProperty("ORACLE_HOME");

System.setProperty("ORACLE_HOME", dbHomePath);
String jlp = java.lang.System.getProperty("java.library.path");
System.setProperty("java.library.path", dbLibraryPath + ":" + jlp);

System.out.println("JLP2 =" + System.getProperty("java.library.path");
System.out.println("OH2  =" + System.getProperty("ORACLE_HOME");

String dsJNDIName = "java:/comp/env/jdbc/orgdbDataSource";
Context ctx = new InitialContext();
ds = (DataSource) ctx.lookup(dsJNDIName);

When I print these variables they look exactly as I want them to look, 
just like they did when everything worked (the top of the mail 
"What I have managed to do"). They look like this:

JLP  =null
OH   =/appl/oracle/product/9.2.0/

JLP2 =/opt/sun-jdk-1.4.2/jre/lib/i386/client:/opt/sun-jdk-1.4.2/jre/lib/i386:/opt/sun-jdk-1.4.2/jre/../lib/i386:/appl/mqm/java/lib/:/opt/mqm/java/lib
OH2  =/appl/oracle/product/9.2.0/lib/:/opt/sun-jdk-1.4.2/jre/lib/i386/client:/opt/sun-jdk-1.4.2/jre/lib/i386:/opt/sun-jdk-1.4.2/jre/../lib/i386:/appl/mqm/java/lib/:/opt/mqm/java/lib

(Notice the change with /opt/sun-jdk-1.4.2/jre/lib/i386/client in the 
start of the path)

My thinking is this (based on what I have read about the ClassLoader):
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/class-loader-howto.html

Since the ojdbc14.jar is placed in /common/lib, the jar doesn't 
include my webapplication-spcific java.library.path since it is supposed 
to be shared by all webapplications. However, if this is the case, it is 
kind of strange since it is my webapplication that uses and loads ojdbc14 
and NOT ojdbc14 that uses my webapplication. Therefore I think that ojdbc14 should 
use my java.library.path.

This is the error I get by the way:

java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
	java.lang.ClassLoader.loadLibrary(ClassLoader.java:1491)
	java.lang.Runtime.loadLibrary0(Runtime.java:788)
	java.lang.System.loadLibrary(System.java:834)
	oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:262)
	oracle.jdbc.driver.OracleConnection.(OracleConnection.java:346) 
        oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
	oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)	
        org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:82)

	org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:300)

	org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:838)

	org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:821)	
	org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:518)
	gu.orgdb.orgobj.Database.getConnection(Database.java:148)
	gu.orgdb.orgobj.UserSession.getConnection(UserSession.java:245)
	gu.orgdb.orgobj.Database.loadOrgUnitsByType(Database.java:2243)	
	gu.orgdb.orgobj.OrgObjectManager.viewOrgUnitsByType(OrgObjectManager.java:218)
	gu.orgdb.orgobj.OrgUnit.getUniversity(OrgUnit.java:264)
	gu.orgdb.util.ImportOrganization.doImport(ImportOrganization.java:46)
	gu.orgdb.web.OrgDBServlet.init(OrgDBServlet.java:72)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
	org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:211)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:805)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:696)
	org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
	java.lang.Thread.run(Thread.java:534)

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message