Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sendfile on Jruby/JRack Tomcat

I'm having an interesting issue when deploying an app to Tomcat. I'm using the Acts_as_flying_saucer gem to convert html to PDF. What the gem/plugin does is render an html view and then uses a java SAX processor to render a standard PDF/1.4 compliant file in the server's TMP directory.

The problem I'm having is when the plugin makes the call to send the file to the browser. It sends a 0 Byte file. Looking at the Rails log, it DOES say that it sent /tmp/41c986f5e6249ce24c7698b6494796e0.pdf

Tomcat log shows a 200 status as if it sent the file. But the file in the /tmp/ directory has info in it and the one sent to the browser is empty.

The best guess I have is that there is something flaky in the send_file method.

It works great from webrick. I've deployed a WAR on a few different Tomcat instances on both Linux and Windows... the logs all seem to show things working fine.

Let me know if more info is needed or if anyone has any ideas on how I could track down this problem.

Thanks, -Jim

like image 311
Jim Wharton Avatar asked Mar 10 '26 12:03

Jim Wharton


1 Answers

It appears that Tomcat does not understand 'X-Sendfile' the way other web servers do.

The "fix" is to comment out:

config.action_dispatch.x_sendfile_header = "X-Sendfile"

in your environments/production.rb

Hope this helps others.

-Jim

like image 68
Jim Wharton Avatar answered Mar 13 '26 01:03

Jim Wharton