ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-users
Jython-users
[Jython-users] Problem with Jythonc and import
by Kent Johnson other posts by this author
Oct 13 2003 8:28PM messages near this date
RE: [Jython-users] newbie needs help :-) | [Jython-users] newbie needs help :-)
I am having a problem importing Java packages in compiled jython code.

For example I have this program that uses log4j:

### test.py

from org.apache.log4j import BasicConfigurator, Logger

__log = Logger.getLogger('DocWindow')

if __name__ == '__main__':
     BasicConfigurator.configure()
     __log.info('this is a test')

If I run this with the command line
 > java -cp "../lib/jython-2.1.jar;../lib/log4j-1.2.8-partial.jar" 
org.python.util.jython test.py

I get the expected output
0 [main] INFO DocWindow  - this is a test

I then compile test.py to test.jar using
 > jythonc --deep --jar test.jar test.py

If I then run from the jar I get an ImportError:
 > java -cp "test.jar;../lib/jython-2.1.jar;../lib/log4j-1.2.8-partial.jar" test
Exception in thread "main" Traceback (innermost last):
   File "D:\Projects\Meccano\editor\test.py", line 0, in main
ImportError: No module named log4j

I have tried also compiling with --core and --all but I get an error during 
the build:

Building archive: test.jar
Tracking java dependencies:
Traceback (innermost last):
   File "E:\jython-2.1\Tools\jythonc\jythonc.py", line 5, in ?
   File "E:\jython-2.1\Tools\jythonc\main.py", line 301, in main
   File "E:\jython-2.1\Tools\jythonc\main.py", line 294, in writeResults
   File "E:\jython-2.1\Tools\jythonc\jar.py", line 98, in dump
   File "E:\jython-2.1\Tools\jythonc\jar.py", line 92, in dumpFiles
   File "E:\jython-2.1\Tools\jythonc\jar.py", line 111, in addPackage
java.util.zip.ZipException: duplicate entry: 
org/python/core/FixedFileWrapper.class
         at 
java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:163)
          ...etc.

I tried with both jython 2.1 and 2.2a0. With 2.2a0 the module compiles with 
--core but the import still fails.

How can I get this import to work?

Thanks!
Kent



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved