4

FFI understands :size_t when running rails through jRuby, but not after using Warbler to create a .war file and running that using java -jar my_project.war or Tomcat.

                       Linux | Windows
-----------------------------+-------------
java -jar              works | doesn't work
tomcat                 works | doesn't work
rails s (using jruby)  works | works

Linux and Windows use the same war file in the comparison.

Here is the top of a backtrace from running java -jar on Windows. (I've edited the beginnings of the file paths in the backtrace).

--- Backtrace
TypeError: unable to resolve type 'size_t'
  find_type at jar:file:/my_project.war/WEB-INF/lib/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/shared/ffi/types.rb:55
  type_size at jar:file:/my_project.war/WEB-INF/lib/jruby-stdlib-1.7.2.jar!/META-INF/jruby.home/lib/ruby/shared/ffi/types.rb:147
SQLAnywhere at my_project.war/WEB-INF/gems/gems/sqlanywhere-ffi-1.0.1/lib/sqlanywhere.rb:13
     (root) at my_project.war/WEB-INF/gems/gems/sqlanywhere-ffi-1.0.1/lib/sqlanywhere.rb:5
    require at org/jruby/RubyKernel.java:1027

When I look at the files in the backtrace, they list various c types, but not size_t.

It seems to me that there are 2 FFIs available to jRuby.

The big difference between the 2, seems to be that only the former understands :size_t.

My question is: Are there 2 different FFIs? If so: how do I make sure that my gem loads the correct ffi? If not: what am I doing wrong?

PS: I'm the author of the sqlanywhere-ffi gem, so if the problem is I'm depending on the wrong thing, I can change it. Currently it has ffi as a depenendency in the gemspec, the gemfile and it requires 'ffi' in the main entry point.

Chris
  • 43
  • 4

1 Answers1

3

(I've edited the beginnings of the file paths in the backtrace).

I guess the full path of your Tomcat-directory contains whitespaces, make sure it doesn't.

This problem did not occur with jruby-1.6 versions.

m0gg
  • 134
  • 1
  • 6
  • Any fixes? Appears with jruby176 – ted Nov 15 '13 at 17:01
  • 1
    Make sure the path to your webapps-directory does not contain whitespaces, that should fix this issue. Unfortunately i had a lot of other unresolved issues with jruby 1.7.6. Dowgrading to 1.7.4 "fixed" them. – m0gg Nov 19 '13 at 10:19