pythonmachine-learningflaskherokupaas

My Heroku python app needs java to be installed


there. I am planning to deploy my ML model on Heroku. I am using 'language_check' library in my project, which requires Java to be installed on the machine. Now, when I deploy my app to Heroku, it is successfully built but the app won't work (most probably because Java is not installed).

Here is my log:

 State changed from starting to up
2020-04-02T16:00:21.174188+00:00 app[web.1]: [2020-04-02 16:00:21 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-04-02T16:00:21.174713+00:00 app[web.1]: [2020-04-02 16:00:21 +0000] [4] [INFO] Listening at: http://0.0.0.0:56448 (4)
2020-04-02T16:00:21.174809+00:00 app[web.1]: [2020-04-02 16:00:21 +0000] [4] [INFO] Using worker: sync
2020-04-02T16:00:21.178572+00:00 app[web.1]: [2020-04-02 16:00:21 +0000] [10] [INFO] Booting worker with pid: 10
2020-04-02T16:00:21.207904+00:00 app[web.1]: [2020-04-02 16:00:21 +0000] [11] [INFO] Booting worker with pid: 11
2020-04-02T16:00:22.074140+00:00 app[web.1]: [2020-04-02 16:00:22 +0000] [11] [ERROR] Exception in worker process
2020-04-02T16:00:22.074185+00:00 app[web.1]: Traceback (most recent call last):
2020-04-02T16:00:22.074186+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 594, in get_server_cmd
2020-04-02T16:00:22.074187+00:00 app[web.1]: cmd = cache['server_cmd']
2020-04-02T16:00:22.074187+00:00 app[web.1]: KeyError: 'server_cmd'
2020-04-02T16:00:22.074188+00:00 app[web.1]:
2020-04-02T16:00:22.074188+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2020-04-02T16:00:22.074188+00:00 app[web.1]:
2020-04-02T16:00:22.074189+00:00 app[web.1]: Traceback (most recent call last):
2020-04-02T16:00:22.074189+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 605, in get_jar_info
2020-04-02T16:00:22.074189+00:00 app[web.1]: java_path, jar_path = cache['jar_info']
2020-04-02T16:00:22.074198+00:00 app[web.1]: KeyError: 'jar_info'
2020-04-02T16:00:22.074198+00:00 app[web.1]:
2020-04-02T16:00:22.074199+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2020-04-02T16:00:22.074199+00:00 app[web.1]:
2020-04-02T16:00:22.074199+00:00 app[web.1]: Traceback (most recent call last):
2020-04-02T16:00:22.074200+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-04-02T16:00:22.074200+00:00 app[web.1]: worker.init_process()
2020-04-02T16:00:22.074200+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-04-02T16:00:22.074201+00:00 app[web.1]: self.load_wsgi()
2020-04-02T16:00:22.074201+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-04-02T16:00:22.074201+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-04-02T16:00:22.074202+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-04-02T16:00:22.074202+00:00 app[web.1]: self.callable = self.load()
2020-04-02T16:00:22.074202+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-04-02T16:00:22.074202+00:00 app[web.1]: return self.load_wsgiapp()
2020-04-02T16:00:22.074203+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-04-02T16:00:22.074203+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-04-02T16:00:22.074203+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2020-04-02T16:00:22.074204+00:00 app[web.1]: mod = importlib.import_module(module)
2020-04-02T16:00:22.074204+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2020-04-02T16:00:22.074205+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-04-02T16:00:22.074205+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2020-04-02T16:00:22.074205+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2020-04-02T16:00:22.074206+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2020-04-02T16:00:22.074206+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2020-04-02T16:00:22.074206+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2020-04-02T16:00:22.074207+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-04-02T16:00:22.074207+00:00 app[web.1]: File "/app/app.py", line 2, in <module>
2020-04-02T16:00:22.074207+00:00 app[web.1]: from src import predict as main_app
2020-04-02T16:00:22.074208+00:00 app[web.1]: File "/app/src/predict.py", line 6, in <module>
2020-04-02T16:00:22.074208+00:00 app[web.1]: from src import nlp_custom
2020-04-02T16:00:22.074208+00:00 app[web.1]: File "/app/src/nlp_custom.py", line 4, in <module>
2020-04-02T16:00:22.074209+00:00 app[web.1]: tool = language_check.LanguageTool('en-US')
2020-04-02T16:00:22.074209+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 196, in __init__
2020-04-02T16:00:22.074209+00:00 app[web.1]: self._start_server_on_free_port()
2020-04-02T16:00:22.074210+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 333, in _start_server_on_free_port
2020-04-02T16:00:22.074210+00:00 app[web.1]: cls._start_local_server()
2020-04-02T16:00:22.074210+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 345, in _start_local_server
2020-04-02T16:00:22.074211+00:00 app[web.1]: server_cmd = get_server_cmd(cls._port)
2020-04-02T16:00:22.074211+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 596, in get_server_cmd
2020-04-02T16:00:22.074211+00:00 app[web.1]: java_path, jar_path = get_jar_info()
2020-04-02T16:00:22.074211+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 609, in get_jar_info
2020-04-02T16:00:22.074212+00:00 app[web.1]: raise JavaError("can't find Java")
2020-04-02T16:00:22.074275+00:00 app[web.1]: language_check.JavaError: can't find Java
2020-04-02T16:00:22.075377+00:00 app[web.1]: [2020-04-02 16:00:22 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-04-02T16:00:22.158963+00:00 app[web.1]: [2020-04-02 16:00:22 +0000] [10] [ERROR] Exception in worker process
2020-04-02T16:00:22.158965+00:00 app[web.1]: Traceback (most recent call last):
2020-04-02T16:00:22.158966+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 594, in get_server_cmd
2020-04-02T16:00:22.158967+00:00 app[web.1]: cmd = cache['server_cmd']
2020-04-02T16:00:22.158967+00:00 app[web.1]: KeyError: 'server_cmd'
2020-04-02T16:00:22.158967+00:00 app[web.1]:
2020-04-02T16:00:22.158968+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2020-04-02T16:00:22.158968+00:00 app[web.1]:
2020-04-02T16:00:22.158969+00:00 app[web.1]: Traceback (most recent call last):
2020-04-02T16:00:22.158970+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 605, in get_jar_info
2020-04-02T16:00:22.158970+00:00 app[web.1]: java_path, jar_path = cache['jar_info']
2020-04-02T16:00:22.158970+00:00 app[web.1]: KeyError: 'jar_info'
2020-04-02T16:00:22.158973+00:00 app[web.1]:
2020-04-02T16:00:22.158973+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2020-04-02T16:00:22.158973+00:00 app[web.1]:
2020-04-02T16:00:22.158974+00:00 app[web.1]: Traceback (most recent call last):
2020-04-02T16:00:22.158974+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-04-02T16:00:22.158974+00:00 app[web.1]: worker.init_process()
2020-04-02T16:00:22.158975+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-04-02T16:00:22.158975+00:00 app[web.1]: self.load_wsgi()
2020-04-02T16:00:22.158976+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-04-02T16:00:22.158976+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-04-02T16:00:22.158976+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-04-02T16:00:22.158977+00:00 app[web.1]: self.callable = self.load()
2020-04-02T16:00:22.158977+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-04-02T16:00:22.158977+00:00 app[web.1]: return self.load_wsgiapp()
2020-04-02T16:00:22.158978+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-04-02T16:00:22.158978+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-04-02T16:00:22.158979+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2020-04-02T16:00:22.158979+00:00 app[web.1]: mod = importlib.import_module(module)
2020-04-02T16:00:22.158999+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2020-04-02T16:00:22.159001+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-04-02T16:00:22.159001+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2020-04-02T16:00:22.159001+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2020-04-02T16:00:22.159002+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2020-04-02T16:00:22.159002+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2020-04-02T16:00:22.159002+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2020-04-02T16:00:22.159004+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-04-02T16:00:22.159004+00:00 app[web.1]: File "/app/app.py", line 2, in <module>
2020-04-02T16:00:22.159005+00:00 app[web.1]: from src import predict as main_app
2020-04-02T16:00:22.159005+00:00 app[web.1]: File "/app/src/predict.py", line 6, in <module>
2020-04-02T16:00:22.159005+00:00 app[web.1]: from src import nlp_custom
2020-04-02T16:00:22.159005+00:00 app[web.1]: File "/app/src/nlp_custom.py", line 4, in <module>
2020-04-02T16:00:22.159005+00:00 app[web.1]: tool = language_check.LanguageTool('en-US')
2020-04-02T16:00:22.159006+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 196, in __init__
2020-04-02T16:00:22.159006+00:00 app[web.1]: self._start_server_on_free_port()
2020-04-02T16:00:22.159006+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 333, in _start_server_on_free_port
2020-04-02T16:00:22.159006+00:00 app[web.1]: cls._start_local_server()
2020-04-02T16:00:22.159007+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 345, in _start_local_server
2020-04-02T16:00:22.159007+00:00 app[web.1]: server_cmd = get_server_cmd(cls._port)
2020-04-02T16:00:22.159007+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 596, in get_server_cmd
2020-04-02T16:00:22.159007+00:00 app[web.1]: java_path, jar_path = get_jar_info()
2020-04-02T16:00:22.159008+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/language_check/__init__.py", line 609, in get_jar_info
2020-04-02T16:00:22.159008+00:00 app[web.1]: raise JavaError("can't find Java")
2020-04-02T16:00:22.159014+00:00 app[web.1]: language_check.JavaError: can't find Java
2020-04-02T16:00:22.159602+00:00 app[web.1]: [2020-04-02 16:00:22 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-04-02T16:00:22.242160+00:00 app[web.1]: Traceback (most recent call last):
2020-04-02T16:00:22.242167+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 209, in run
2020-04-02T16:00:22.242645+00:00 app[web.1]: self.sleep()
2020-04-02T16:00:22.242650+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 357, in sleep
2020-04-02T16:00:22.243016+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2020-04-02T16:00:22.243017+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2020-04-02T16:00:22.243213+00:00 app[web.1]: self.reap_workers()
2020-04-02T16:00:22.243214+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-04-02T16:00:22.243433+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2020-04-02T16:00:22.243464+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2020-04-02T16:00:22.243465+00:00 app[web.1]:
2020-04-02T16:00:22.243465+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2020-04-02T16:00:22.243465+00:00 app[web.1]:
2020-04-02T16:00:22.243468+00:00 app[web.1]: Traceback (most recent call last):
2020-04-02T16:00:22.243485+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2020-04-02T16:00:22.243587+00:00 app[web.1]: sys.exit(run())
2020-04-02T16:00:22.243616+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
2020-04-02T16:00:22.243708+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2020-04-02T16:00:22.243738+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 228, in run
2020-04-02T16:00:22.243921+00:00 app[web.1]: super().run()
2020-04-02T16:00:22.243924+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
2020-04-02T16:00:22.244084+00:00 app[web.1]: Arbiter(self).run()
2020-04-02T16:00:22.244085+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 229, in run
2020-04-02T16:00:22.244227+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2020-04-02T16:00:22.244245+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 342, in halt
2020-04-02T16:00:22.244574+00:00 app[web.1]: self.stop()
2020-04-02T16:00:22.244578+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 393, in stop
2020-04-02T16:00:22.244939+00:00 app[web.1]: time.sleep(0.1)
2020-04-02T16:00:22.244943+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2020-04-02T16:00:22.245266+00:00 app[web.1]: self.reap_workers()
2020-04-02T16:00:22.245270+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-04-02T16:00:22.245760+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2020-04-02T16:00:22.245761+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2020-04-02T16:00:22.338198+00:00 heroku[web.1]: State changed from up to crashed

I am new to Heroku. Please help, and suggest some alternatives where I can manually install Java.


Solution

  • Add the JVM buildpack to your app by running:

    $ heroku buildpacks:add heroku/jvm
    

    Then redeploy