Forum: JRuby (LoadError) Could not load FFI Provider - when using jruby-core jars (1.7.4)

2cda9758c673339fc208518b9756479b?d=identicon&s=25 Colin Surprenant (Guest)
on 2013-06-20 20:03
(Received via mailing list)
Hi,

I am getting this exception with FFI when using jruby-core jars but NOT
when using jruby-complete.jar:

org.jruby.exceptions.RaiseException: (LoadError) Could not load FFI
Provider: (NotImplementedError) FFI not available: Could not initialize
class com.kenai.jffi.Foreign$InstanceHolder
 See http://jira.codehaus.org/browse/JRUBY-4583

It seems that the libffi libraries are not included in any of the
jruby-core jars. The following is included in jruby-complete.jar but NOT
in
any of the jruby-core jars:

jni/x86_64-FreeBSD/
jni/x86_64-FreeBSD/libjffi-1.2.so
jni/x86_64-Linux/
jni/x86_64-Linux/libjffi-1.2.so
jni/x86_64-SunOS/
jni/x86_64-SunOS/libjffi-1.2.so
jni/x86_64-Windows/
jni/x86_64-Windows/jffi-1.2.dll

I am trying to figure how I could include these into my dependencies
alongside the jruby-core jars. Any ideas?

Thanks,
Colin
5993756d2b69ce0bc16df3318c240d54?d=identicon&s=25 Wayne Meissner (Guest)
on 2013-06-21 01:15
(Received via mailing list)
It depends on what dependency management you're using.

If maven-ish (or anything that can use a maven repo, such as gradle,
ivy, etc), then add a dependency on com.github.jnr:jffi, something
like:

<dependency>
  <groupId>com.github.jnr</groupId>
  <artifactId>jffi</artifactId>
  <version>1.2.7</version>
</dependency>

Or, just download and add
https://oss.sonatype.org/content/repositories/rele...
to your classpath.
2cda9758c673339fc208518b9756479b?d=identicon&s=25 Colin Surprenant (Guest)
on 2013-06-21 07:46
(Received via mailing list)
Wayne,

I am using the jruby-core 1.7.4 artifact as a dependency which depends
on
jffi 1.2.5 so jffi-1.2.5.jar is downloaded but not
jffi-1.2.5-native.jar.

I am using Ivy and currently stuck at trying to include
jffi-1.2.5-native.jar as an extra dependency.

Colin
5993756d2b69ce0bc16df3318c240d54?d=identicon&s=25 Wayne Meissner (Guest)
on 2013-06-21 09:07
(Received via mailing list)
Ahh, thats a fairly easy fix - since the binaries are packaged
separately to the main pom, you need an explicit dependency on the
native assembly.

<dependency>
      <groupId>com.github.jnr</groupId>
      <artifactId>jffi</artifactId>
      <version>1.2.7</version>
      <scope>runtime</scope>
      <classifier>native</classifier>
    </dependency>

Why that isn't in jruby-core itself, or at least getting pulled in via
the jruby-core -> jnr-ffi dependency chain, I'm not too sure.
C37cb1a6a19e23f067aae6ccb2d0de4b?d=identicon&s=25 Manuel Ramos (Guest)
on 2013-06-21 10:37
(Received via mailing list)
Hi I think that core jar dont include things thats not core ... For a
jar
with dependeces its better to use complete jar and then include
additional
jars at classpath. I think that this includes could be posible even with
core but things will be more difficult... Because you must do again work
thats someone did to bundle complete jar container.

Regards
El 20/06/2013 20:03, "Colin Surprenant" <colin.surprenant@gmail.com>
escribi:
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 kristian (Guest)
on 2013-06-21 11:17
(Received via mailing list)
the jruby-core artifact should pull in exactly the same jars as
jruby-complete artifact.

looking at
$mvn dependency:tree
demo:demo:jar:demo
[INFO] \- org.jruby:jruby-core:jar:1.7.4:compile
[INFO]    +- org.jruby:jruby-stdlib:jar:1.7.4:compile
[INFO]    +- org.jruby.joni:joni:jar:2.0.0:compile
[INFO]    +- com.github.jnr:jnr-netdb:jar:1.1.2:compile
[INFO]    +- com.github.jnr:jnr-enxio:jar:0.4:compile
[INFO]    +- com.github.jnr:jnr-unixsocket:jar:0.3:compile
[INFO]    +- com.github.jnr:jnr-posix:jar:2.5.2:compile
[INFO]    +- org.jruby.extras:bytelist:jar:1.0.10:compile
[INFO]    +- com.github.jnr:jnr-constants:jar:0.8.4:compile
[INFO]    +- org.jruby.jcodings:jcodings:jar:1.0.10:compile
[INFO]    +- com.github.jnr:jffi:jar:1.2.5:compile
[INFO]    +- org.yaml:snakeyaml:jar:1.11:compile
[INFO]    +- jline:jline:jar:2.7:compile
[INFO]    +- joda-time:joda-time:jar:2.1:compile
[INFO]    +- com.jcraft:jzlib:jar:1.1.2:compile
[INFO]    +- com.headius:invokebinder:jar:1.2:compile
[INFO]    \- com.github.jnr:jnr-ffi:jar:1.0.4:compile
[INFO]       +- com.github.jnr:jffi:jar:native:1.2.7:runtime
[INFO]       \- com.github.jnr:jnr-x86asm:jar:1.0.2:compile

with a pom with only jruby-core as depdenceny. this shows that
com.github.jnr:jffi:jar:native:1.2.7:runtime is pulled in by the
dependency
manager.

so I am still sure that jruby-core+transitive dependencies is
essentially
the same as jruby-complete. could it be that there is loading issue of
the
native lib - just guessing ?

- christian
2cda9758c673339fc208518b9756479b?d=identicon&s=25 Colin Surprenant (Guest)
on 2013-06-21 20:13
(Received via mailing list)
ah-ah! classifier! thanks, I got it to include the native dependency and
for the record here's my Ivy config:

  <dependencies>
    <dependency org="org.jruby" name="jruby-core" rev="1.7.4"
conf="default" />
    <dependency org="com.github.jnr" name="jffi" rev="1.2.5"
conf="default">
      <artifact name="jffi" type="jar" />
      <artifact name="jffi" type="jar" m:classifier="native"/>
    </dependency>
  </dependencies>

and "classifier" is needed in the retrieve pattern, with something like:

ant.retrieve "pattern" =>
"[conf]/[artifact](-[classifier])-[revision].[ext]"

Thanks,
Colin
2cda9758c673339fc208518b9756479b?d=identicon&s=25 Colin Surprenant (Guest)
on 2013-06-21 20:36
(Received via mailing list)
I am not very good with both Ivy & Maven so this might just be caused by
my
weakness with these tools... A basic transitive dependency on jruby-core
with Ivy like this:

<dependency org="org.jruby" name="jruby-core" rev="1.7.4" conf="default"
/>

does not include jffi-native.

so looking at your dependency tree, jffi-native is in the maven
"runtime"
scope. I have tried without success to specify a runtime conf in Ivy to
include jffi-native. Again this might just be me not doing it right.

Manuel: jruby-complete can be useful but is not a good option when you
are
also dealing with other dependencies - with jruby-complete, it is not
possible to resolve conflicting jars etc.

Colin
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 kristian (Guest)
on 2013-06-21 20:48
(Received via mailing list)
it might very well be a Ivy thingy ;) great that you found a solution.

maybe it  is worth to declare com.github.jnr:jffi:jar:native:1.2.7 with
scope compile to keep the usage of jruby-core simple for Ivy users :)

-christian



On Fri, Jun 21, 2013 at 7:34 PM, Colin Surprenant <
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.