Issue1652

classification
Title: JARs not found using java.ext.dir and java.class.path
Type: Severity: normal
Components: Versions: Jython 2.5
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: ddaniels, fwierzbicki, zyasoft
Priority: Keywords:

Created on 2010-09-08.16:22:48 by ddaniels, last changed 2014-05-22.00:17:58 by zyasoft.

Files
File name Uploaded Description Edit Remove
jar_issue.tar.gz ddaniels, 2010-09-08.16:22:47 example py script and postgreSQL JDBC jar file
Messages
msg6049 (view) Author: Doug Daniels (ddaniels) Date: 2010-09-08.16:22:47
I'm having trouble loading classes from a JAR file using the java.ext.dir or java.class.path properties passed to jython as -D arguments.

I'm using the PostgreSQL 8.4 JDBC JAR to test this, which is attached along with a test script.

When I run:
  jython -Djava.class.path=jar/postgresql-8.4-701.jdbc4.jar postgres_jar_loader.py

The postgres Driver class is not found:

Property java.ext.dirs:  [/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext]
Property java.class.path:  [jar/postgresql-8.4-701.jdbc4.jar]
Unable to import Driver class
Traceback (most recent call last):
  File "postgres_jar_loader.py", line 11, in <module>
    import org.postgresql.Driver
ImportError: No module named Driver

When I run:

  jython -Djava.ext.dirs=jar postgres_jar_loader.py

The same thing happens.

However, if I set the CLASSPATH env var, everything works:

export CLASSPATH="jar/postgresql-8.4-701.jdbc4.jar"
jython postgres_jar_loader.py

Property java.ext.dirs:  [/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext]
Property java.class.path:  [/opt/local/share/java/jython/jython.jar:jar/postgresql-8.4-701.jdbc4.jar]
Successfully imported Driver class

Is there an issue with passing these arguments to jython with the -D option?

This is on a 32-bit Mac running OS 10.6 with jython 2.5.1 installed via port.
msg8517 (view) Author: Jim Baker (zyasoft) Date: 2014-05-22.00:17:57
This is a problem with how JDBC resolves a specific driver - it must be in the CLASSPATH or the equivalent of your container. See for example http://www.jython.org/jythonbook/en/1.0/DatabasesAndJython.html#getting-started

There is other ways of making this work, see also
http://www.jython.org/jythonbook/en/1.0/appendixB.html#working-with-classpath
History
Date User Action Args
2014-05-22 00:17:58zyasoftsetstatus: open -> closed
resolution: invalid
messages: + msg8517
nosy: + zyasoft
2013-02-26 17:34:35fwierzbickisetnosy: + fwierzbicki
2013-02-20 19:00:46fwierzbickisetversions: + Jython 2.5, - 2.5.1
2010-09-08 16:22:48ddanielscreate