Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jars in manifest file not loaded and causes ModuleNotFoundError'>: No module named 'org.apache' #323

Open
lfcnassif opened this issue Apr 23, 2021 · 6 comments

Comments

@lfcnassif
Copy link

First, thank you all for this great project!
My app has the following structure:
./app.jar
./lib/lib1.jar
./lib/lib2.jar
...
My python script (called by java app) imports some classes from jars in lib folder. When executing java -jar app.jar, it throws jep.JepException: <class 'ModuleNotFoundError'>: No module named 'org.apache' for example. But all libraries are listed in app.jar manifest file and are used fine from app.jar embedded classes.

If I change current dir to lib folder and executes java -jar ../app.jar no error is thrown and the python script can access the java libraries. Default java classpath uses . directory.

Using jep-3.9.1 on Windows 10 with Oracle java 8 x64 and on Ubuntu 20.04 with Liberica OpenJDK 8 full.

@lfcnassif
Copy link
Author

Embedded manifest zipped below:

MANIFEST.zip

@bsteffensmeier
Copy link
Member

Jep has the concept of a ClassEnquirer which tells the python envionment which classes are available in python. I suspect your problem lies with the default implementation. I am not very familiar with this code but it appears to be reading the manifest of every jar in the classpath and processing every library specified int he manifest so it seems like your case should work. I recommend debugging into the ClassList to try to determine if it is processing your manifest and finding the referenced libraries.

@lfcnassif
Copy link
Author

@bsteffensmeier thank you for the answer, will try to debug when some time is available and report back here.

@reacan
Copy link

reacan commented May 29, 2021

If I change current dir to lib folder and executes java -jar ../app.jar no error is thrown and the python script can access the java libraries. Default java classpath uses . directory.

I had the exact same issue when your application with all the dependencies was set up in a Linux environment using a regular user account. When the application and all the dependencies were set up using the root account the application could be launched from any directory without an error. Hope this info will be of some help in case you haven't solved this issue yet.

@lfcnassif
Copy link
Author

@bsteffensmeier sorry for late reply, just had time to debug it. The issue is in this line https://github.com/ninia/jep/blob/dev_3.9/src/main/java/jep/ClassList.java#L120

file.getParent() is returning null because file is not absolute. Adding a simple check for null and using just relativePath or using file.getAbsoluteFile().getParent() fixes this issue. I can send a PR if needed.

@ndjensen
Copy link
Member

ndjensen commented Sep 5, 2024

Unfortunately, this issue appears to have been missed and forgotten about. I think the fix would be a good fix in case others encounter this problem. @lfcnassif, are you still interested in submitting a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants