PermissionDenied Error when using with j4rs #2315
-
I'm using j4rs to run java code by invoking a jar file. The code works fine when I run the code using rust. However, it will throw the following error when I invoke the same function from python:
The code panicked at the line of code for adding the jar file to class path. Here is the permission of the jar file:
Any idea what's going on and how to fix it? Please let me know if you need more information! Here is a repo that could reproduce the error: https://github.com/wangxiaoying/pyo3-j4rs-example Both |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I think we can't say much about this without a reproducing example, or at least the full code you're running. For example, in the link you gave there is no |
Beta Was this translation helpful? Give feedback.
-
Here is a repo with minimum code that could reproduce the result: https://github.com/wangxiaoying/pyo3-j4rs-example. Both |
Beta Was this translation helpful? Give feedback.
-
Thank you! I'm getting a different error
but the cause is probably the same: j4rs tries to find the You need to set the proper path with https://docs.rs/j4rs/latest/j4rs/struct.JvmBuilder.html#method.with_base_path - this worked for me:
but of course the path will be different for different targets, and after deployment, so you probably need to add another env. var for it. |
Beta Was this translation helpful? Give feedback.
Thank you! I'm getting a different error
but the cause is probably the same:
j4rs tries to find the
jassets
path which is undertarget/debug/jassets
. It tries to find that in the same directory (or up) of the current executable. For Rust-only, this is undertarget/debug/...
which works. For Python, it is/usr/bin/python
, and there is no "jassets" there.You need to set the proper path with https://docs.rs/j4rs/latest/j4rs/struct.JvmBuilder.html#method.with_base_path - this worked for me: