Same code fails in the Django view but works in the command-line

Clash Royale CLAN TAG#URR8PPP
Same code fails in the Django view but works in the command-line
What can make a Django view fail, while the same code works well when it's called from the command-line?
Django
Below is the simple view I'm calling:
from snappy import ProductIO
def test(request):
path_sar = '<path>/file.dim'
sar_pre_product = ProductIO.readProduct(path_sar)
Snappy is the python client to the java API of ESA SNAP.
This issue seems to be specific to Python web frameworks, since the same code failed also with Flask for the same reason, returning a RuntimeError at ... java.lang.NullPointerException.
Flask
RuntimeError at ... java.lang.NullPointerException
Now, the code below works correctly from the command-line, and it works also when that same script is called with subprocess.call(..., shell=False) from inside the Django view (which is not really a nice workaround).
subprocess.call(..., shell=False)
Any idea if Django is just failing to automatically add to its path certain java libraries already in the classpath when the script is run in the command-line?
Django
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.