0

My app is crashing on Heroku but localhost works without any issue

Log:

heroku router - - at=info method=POST path="/documents" host=www.getmehired.my request_id=368bcdf4-a236-4b40-af87-5f7c801d6654 fwd="61.6.109.144,162.158.165.159" dyno=web.1 connect=1ms service=3562ms status=500 bytes=1669 protocol=http
app web.1 - Completed 500 Internal Server Error in 3224ms (ActiveRecord: 30.5ms)
app web.1 - Errno::ENOENT (No such file or directory - java):
app web.1 - app/models/document.rb:24:in `update_information'
app web.1 - app/controllers/documents_controller.rb:6:in `create'

Dyno:

web bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development} ON
redis redis-server OFF
worker bundle exec sidekiq -c 3 ON

Documents_controller (using paperclip & aws to upload docs:

  def create
    @doc = Document.new(doc_params)
    if @doc.save
      @doc.update_information
      redirect_to users_edit_path
    else
      redirect_to root_path
    end
  end

Document model:

  def update_information
    cv = Yomu.new(self.cv.url)
    # THE NEXT COMMAND -> CRASH
    self.num_of_pages = cv.metadata['xmpTPg:NPages'] if cv.metadata['xmpTPg:NPages']
    self.num_of_characters = cv.text.size
    self.num_of_words = cv.text.split.size
    self.file_extension = self.cv_file_name.split('.').reverse.first
    self.file_updated_at = cv.metadata['modified'] || cv.metadata['Creation-Date'] || Time.now
    self.file_created_at =  cv.metadata['Creation-Date'] || Time.now
    self.save!
  end
Petr
  • 1,853
  • 2
  • 25
  • 49

1 Answers1

1

Read the following instructions

Installation and Dependencies

Java Runtime

Yomu packages the Apache Tika application jar and requires a working JRE for it to work.

The error you are receiving Errno::ENOENT (No such file or directory - java): is caused from the missing installation of the Java Runtime Environment on your Heroku Server.

As I can read here, I believe it may not be possible to install on Heroku the JRE.

I am quoting the following answers and you should try this options:

  1. If you are using the Heroku-16 Stack

you can add jvm as a buildpack and you don't need to configure paths or anything else. Just make sure to have it set as your first buildpack. I tried it with Yomu/Henkei and it worked for me.

  1. If you are using the Cedar Stack

then a JDK is available to you at: /usr/lib/jvm/java-6-openjdk I'm not sure how Yomu finds your Java install, but it's probably looking in JAVA_HOME. If so then setting JAVA_HOME on Heroku should make it work:

heroku config:add JAVA_HOME=/usr/lib/jvm/java-6-openjdk
  1. Third answer

a java runtime (a JRE, like the documentation said). Installing a JRE as an addon is not (yet?) supported on Heroku. Solution: Try other gems not based on JRE

Community
  • 1
  • 1
Fabrizio Bertoglio
  • 5,890
  • 4
  • 16
  • 57
  • Thanks, I will have a look but it's strange because I am using YOMU in other app on Heroku and never had any problem. I tried to version it gem 'yomu', '~> 0.1.5' but didn't help.. ~ since it's working somewhere else, it should definitely work in my new app too – Petr Nov 19 '17 at 11:59
  • The buildpack does work. My other app is running on cedar-14 so this might be reason why does it work without any issue. Thank you for your help – Petr Nov 19 '17 at 13:09
  • @Dudis yes, also my apps run on cedar-14. You can check in your app terminal `heroku run echo $JAVA_HOME`, I tested on my deployment and it returns `/usr/lib/jvm/java-8-openjdk-amd64 ` otherwise you can search info on how to set `$JAVA_HOME` for your instance https://stackoverflow.com/questions/9823487/cant-deploy-to-heroku-the-app-with-rjb-gem#9891161 – Fabrizio Bertoglio Nov 19 '17 at 13:56