• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Jython code throws ImportError when invoked from a Java jar

 
Ranch Hand
Posts: 250
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

I am trying to invoke a Python script from a Spring Boot application which is bundled as a JAR. I added Maven dependency for Jython Standalone JAR. The following code throws error at the execfile call (the code is able to get the Python file as input stream correctly):


Error thrown:


My Python script is using the following imports:

import sys
import argparse
import re
import json

I assume that it is probably happening because I am unable to set the property "python.path", but I am not sure how could I do that (the Jython JAR is being bundled under BOOT-INF/lib by Spring Boot). Also, there is no way for me to actually provide an absolute path for the Python installation (if that is what Jython expects) as the JAR would be deployed on a PaaS where file-system access is not enabled.

Appreciate your help in solving this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic