  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Struts - A MVC web framework | | Tomcat - JSP/Servlet container | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | | JSP - A mailing list about Java Server Pages specification and reference | |
Struts & Hibernate
|
|
|
  | | | Tomcat and webapplication-specific java.library.path | Tomcat and webapplication-specific java.library.path 2004-01-16 - By Erik Winl�f
Back
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 ("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 (See http://jdk-1.ora-code.com).4.2/jre/lib/i386/client:/opt/sun-jdk-1 (See http://jdk-1.ora-code.com).4.2/jre/lib/i386: /opt/sun-jdk-1 (See http://jdk-1.ora-code.com).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 (See http://jdk-1.ora-code.com).4.2/jre/lib/i386/client: /opt/sun-jdk-1 (See http://jdk-1.ora-code.com).4.2/jre/lib/i386:/opt/sun-jdk-1 (See http://jdk-1.ora-code.com).4.2/jre/../lib/i386:/appl/mqm /java/lib/:/opt/mqm/java/lib
(Notice the change with /opt/sun-jdk-1 (See http://jdk-1.ora-code.com).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 (See http://cat-5.ora-code.com).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 (ClassLoader.java:1491) java.lang.Runtime (Runtime.java:788) java.lang.System (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  (DriverConnectionFactory.java:82) org.apache.commons.dbcp.PoolableConnectionFactory  (PoolableConnectionFactory.java:300) org.apache.commons.dbcp.BasicDataSource  (BasicDataSource.java:838) org.apache.commons.dbcp.BasicDataSource (BasicDataSource.java :821) org.apache.commons.dbcp.BasicDataSource (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 (ErrorReportValve.java:164) org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:211) org.apache.coyote.http11.Http11Processor (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 (Thread.java:534)
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected) For additional commands, e-mail: tomcat-user-help@(protected)
|
|
 |