I have jar/zip file contains properties file called accord.properties under classes folder.
Zip/Jar file:
+classes
+accord.properties
I am reading file as:
from java.util import Properties
from java.io import File, FileInputStream
def loadPropsFil(propsFil):
print(propsFil)
inStream = FileInputStream(propsFil)
propFil = Properties()
propFil.load(inStream)
return propFil
pFile = loadPropsFil("/accord.properties")
print(pFile)
while running in Tomcat server, I am getting error as
Exception stack is: 1. accord.properties (No such file or directory) (java.io.FileNotFoundException) java.io.FileInputStream:-2 (null)
2. null(org.python.core.PyException) org.python.core.Py:512 (null)
3. java.io.FileNotFoundException: java.io.FileNotFoundException: accord.properties (No such file or directory) in <script> at line number 34 (javax.script.ScriptException)
Tried with
pFile = loadPropsFil("accord.properties")
and
pFile = loadPropsFil("classpath:accord.properties")
same error.
EDIT
inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("accord.properties")
strProp = Properties().load(inStream) # line 38
options.outputfile=strProp.getProperty("OUTPUT_DIR")
Here inStream gives null and causes NullPointer Exception.
Error:
java.lang.NullPointerException: java.lang.NullPointerException in <script> at line number 38 (javax.script.ScriptException)