Issue1422

classification
Title: standalone jython doesn't load jars in classpath on solaris
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.5
process
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, gschenke, projectmoon
Priority: Keywords:

Created on 2009-08-05.10:22:52 by gschenke, last changed 2013-02-19.21:15:02 by fwierzbicki.

Messages
msg4988 (view) Author: Gerald Schenke (gschenke) Date: 2009-08-05.10:22:51
I used the jython_installer_2.5.0.jar to create a standalone jython.jar.
Started a script that needs a java-class from an external jar with:
java -classpath myjavacode.jar:jython.jar org.python.util.jython myscript.py
The myjavacode.jar is not loaded and the script fails with 
ImportError: No module named mymodule

bash-3.00$ java -version
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Server VM (build 1.5.0_14-b03, mixed mode)

bash-3.00$ uname -a
SunOS spare01 5.10 Generic_118833-17 sun4u sparc SUNW,Sun-Fire-V440

BTW: On Linux the same command works as expected, although i noticed
something strange when trying to use org.apache.log4j.BasicConfigurator
"import org.apache.log4j.BasicConfigurator" works on linux, not on
solaris (both use standalone jython.jar)
"import org.apache" does NOT work on linux or solaris (standalone) but
does work if using an installed version of jython...
msg5638 (view) Author: projectmoon (projectmoon) Date: 2010-04-05.22:40:27
I can confirm this as well on the release version of Jython 2.5.1. I tested it on both Ubuntu 8.04 and Mac OS X Snow Leopard. The results were the same. After searching around on Google for similar problems, I found some workarounds. However, none of them worked. After delving into the Jython source code, I found sort of a ghetto workaround.

By calling PySystemState.add_extdir(String), you can put jars into Jython at runtime, and import statements should work as per the norm. Of course, the trick is getting the directory with your jars into your program. In my case I wound up passing an environment variable. You could conceivably also pass Java a -Dproperty, or hard code it.
History
Date User Action Args
2013-02-19 21:15:02fwierzbickisetversions: - Jython 2.7
2013-02-19 21:14:51fwierzbickisetresolution: remind
versions: + Jython 2.5, Jython 2.7, - 2.5.0
2010-04-05 22:40:28projectmoonsetnosy: + projectmoon
messages: + msg5638
2009-08-06 14:57:32fwierzbickisetnosy: + fwierzbicki
2009-08-05 10:22:52gschenkecreate