Issue1776

classification
Title: Packages in JARs that are dynamically added to sys.path cannot be imported
Type: behaviour Severity: critical
Components: Core Versions: Jython 2.5
Milestone:
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: djain, fwierzbicki, zyasoft
Priority: high Keywords:

Created on 2011-07-22.15:33:53 by djain, last changed 2014-06-19.05:10:48 by zyasoft.

Messages
msg6577 (view) Author: Dominik Jain (djain) Date: 2011-07-22.15:33:52
Adding a JAR file to the classpath by appending its location to sys.path does not make the packages contained in the JAR available.

I thought this was related to #1455, which was supposedly fixed, but it doesn't work. In Jython 2.2, if somelib.jar was located in /path/to/somelib.jar and contained the package somepackage, one could do the following:

import sys
sys.path.append("/path/to/somelib.jar")
import somepackage

This will not work in either Jython 2.5.1 or 2.5.2 (somepackage is not available). 
However, if the class files are not in a JAR but in a directory, e.g. /path/to/somebin, it will also work with the two new releases:

import sys
sys.path.append("/path/to/somebin")
import somepackage

Works fine. 

You can try this with any JAR. So far I haven't found one I could import with 2.5.1/2.5.2.

Because the issue breaks backward compatibility with Jython 2.2 and I am unaware of an equally simple way of dynamically loading JARs, I consider this to be critical.
msg6588 (view) Author: Dominik Jain (djain) Date: 2011-07-29.12:16:36
I have now tested Jython 2.5.0 and found that the bug was *not* yet present in that version.
msg6589 (view) Author: Dominik Jain (djain) Date: 2011-07-29.12:46:52
I have now found out that the problem also occurs with 2.5.0 if one runs jython from a single JAR that also contains the jython standard library.

The root cause of the problem is the use of a single jython JAR. It makes dynamic imports of other JARs via sys.path impossible.
msg8709 (view) Author: Jim Baker (zyasoft) Date: 2014-06-19.05:10:47
Running Jython with java -jar jython.jar can cause this issue, but that's a well-known problem in Java. There are some possible workarounds like this one: http://www.jython.org/jythonbook/en/1.0/appendixB.html#working-with-classpath

Otherwise, I use this capability all of the time in Clamp, so I know it works.
History
Date User Action Args
2014-06-19 05:10:48zyasoftsetstatus: open -> closed
resolution: invalid
messages: + msg8709
nosy: + zyasoft
2013-02-25 18:36:41fwierzbickisetpriority: high
nosy: + fwierzbicki
versions: + Jython 2.5, - 2.5.1, 2.5.2
2011-07-29 12:46:52djainsetmessages: + msg6589
2011-07-29 12:16:37djainsetmessages: + msg6588
2011-07-22 15:33:53djaincreate