Jasper Report: KeyError: 'JAVA_HOME'

Hi @luisfmfernandes,
I’m trying to integrate Jasper in a new setup and I came across the following error on bench install-app…

Note: I have already installed pyjnius

ubuntu@erpnext-local:~/frappe-bench$ bench install-app jasper_erpnext_report
Installing jasper_erpnext_report…
pyjnius is not installed: ‘JAVA_HOME’
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 16, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/commands.py”, line 163, in install_app
_install_app(app, verbose=context.verbose)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/installer.py”, line 122, in install_app
sync_for(name, force=True, sync_everything=True, verbose=verbose)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/sync.py”, line 43, in sync_for
import_file_by_path(doc_path, force=force)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 54, in import_file_by_path
import_doc(doc, force=force, data_import=data_import, pre_process=pre_process)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 122, in import_doc
doc.insert()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 209, in insert
self.run_post_save_methods()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 606, in run_post_save_methods
self.run_method(“on_update”)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 550, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 705, in composer
return composed(self, method, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 688, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 544, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 123, in on_update
self.run_module_method(“on_doctype_update”)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 132, in run_module_method
module = load_doctype_module(self.name, self.module)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/init.py”, line 64, in load_doctype_module
doctype_python_modules[key] = frappe.get_module(get_module_name(doctype, module, prefix))
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 583, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module
import(name)
File “/home/ubuntu/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/jasper_erpnext_report/doctype/jasper_reports/jasper_reports.py”, line 15, in
from jasper_erpnext_report.core.JasperRoot import JasperRoot
File “/home/ubuntu/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperRoot.py”, line 11, in
import JasperServer as Js, JasperLocal as Jl, JasperBase as Jb
File “/home/ubuntu/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperLocal.py”, line 15, in
from jasper_erpnext_report.jasper_reports.FrappeDataSource import _JasperCustomDataSource
File “/home/ubuntu/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/jasper_reports/FrappeDataSource.py”, line 4, in
from jnius import PythonJavaClass, java_method
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/jnius/init.py”, line 13, in
from .reflect import *
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/jnius/reflect.py”, line 14, in
class Class(with_metaclass(MetaJavaClass, JavaClass)):
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/six.py”, line 808, in new
return meta(name, bases, d)
File “jnius/jnius_export_class.pxi”, line 43, in jnius.MetaJavaClass.new (jnius/jnius.c:17081)
File “jnius/jnius_export_class.pxi”, line 65, in jnius.MetaJavaClass.resolve_class (jnius/jnius.c:17477)
File “jnius/jnius_env.pxi”, line 11, in jnius.get_jnienv (jnius/jnius.c:3317)
File “jnius/jnius_jvm_dlopen.pxi”, line 89, in jnius.get_platform_jnienv (jnius/jnius.c:3245)
File “jnius/jnius_jvm_dlopen.pxi”, line 48, in jnius.create_jnienv (jnius/jnius.c:2644)
File “/home/ubuntu/frappe-bench/env/lib/python2.7/UserDict.py”, line 23, in getitem
raise KeyError(key)
KeyError: ‘JAVA_HOME’

Hi.

Normally pyjnius only install if you have java installed. What i see is that JAVA_HOME is not set.

Try echo $JAVA_HOME to see if you have JAVA_HOME variable set. If not find out where is java idk installed and set JAVA_HOME variable.

Also, i will install again in vagrant (this weekend) to see if every thing is ok. I get others people reporting that they can’t get install-app.

Also, tell me how did you install pyjnius. I have been problems when i install from pip install pyjnius. Check, also, if pyjnius is installed in frappe-bench/env/… virtual folder and not globally.

The best way is to install has i told you before.

2 Likes

Yes. setting JAVA_HOME did the trick. I also had to Export JAVA_HOME.

Thanks @luisfmfernandes