Gradle 1.12-rc-2 fails with UnsatisfiedLinkError on some Linux versions

My gradle build is kicked off by a Linux shell script runs gradlew with SunJDK 1.6.0_45.

It works fine one a box “Linux XXX 2.6.32-358.23.2.el6.x86_64 #1 SMP Sat Sep 14 05:32:37 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux”.

It fails on a box “Linux YYY 2.6.9-103.EL.msdw.1largesmp #1 SMP Mon Dec 12 13:34:16 EST 2011 x86_64 x86_64 x86_64 GNU/Linux” with the following error:

FAILURE: Build failed with an exception.

  • What went wrong: net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.symlink(Ljava/lang/String;Ljava/lang/String;Lnet/rubygrapefruit/platform/internal/FunctionResult;)V

  • Try: Run with --info or --debug option to get more log output.

  • Exception is: java.lang.UnsatisfiedLinkError: net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.symlink(Ljava/lang/String;Ljava/lang/String;Lnet/rubygrapefruit/platform/internal/FunctionResult;)V

at net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.symlink(Native Method)

at net.rubygrapefruit.platform.internal.DefaultPosixFiles.symlink(DefaultPosixFiles.java:64)

at org.gradle.internal.nativeplatform.filesystem.NativePlatformBackedSymlink.symlink(NativePlatformBackedSymlink.java:33)

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.tryCreateSymbolicLink(GenericFileSystem.java:53)

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.probeCanCreateSymbolicLink(GenericFileSystem.java:121)

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.(GenericFileSystem.java:86)

at org.gradle.internal.nativeplatform.filesystem.FileSystemServices.createFileSystem(FileSystemServices.java:47)

at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)

at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:323)

at org.gradle.internal.service.DefaultServiceRegistry.access$1200(DefaultServiceRegistry.java:53)

at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:636)

at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:592)

at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:434)

at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:474)

at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:295)

at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:279)

at org.gradle.internal.nativeplatform.services.FileSystems.getDefault(FileSystems.java:22)

at org.gradle.initialization.DefaultCommandLineConverter.(DefaultCommandLineConverter.java:64)

at org.gradle.launcher.cli.BuildActionsFactory.(BuildActionsFactory.java:71)

at org.gradle.launcher.cli.CommandLineActionFactory.createActionFactories(CommandLineActionFactory.java:66)

at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:186)

at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)

at org.gradle.launcher.Main.doAction(Main.java:46)

at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)

at org.gradle.launcher.Main.main(Main.java:37)

at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)

at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)

at org.gradle.launcher.GradleMain.main(GradleMain.java:23)

at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)

at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)

at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:55)

Thanks for the bug report. I’ve raised GRADLE-3076 to track this.

There are a couple of things you could do to help us fix this: - Try using JDK 1.7 and Gradle 1.12-rc-2 on the failing Linux machine - Clone the native platform project (https://github.com/adammurdoch/native-platform) and run ‘./gradlew test’.

Which distribution and version of linux is the machine that fails using? Are you using the 32 bit or 64 bit JDK?

Can you also try running ‘GRADLE_OPTS=-Dorg.gradle.native=false gradle -v’ on the failing machine.

I am also seeing this error on my Mac. I tried running gradlew test and got the following exception:

Exception in thread “main” java.lang.NoClassDefFoundError: org/gradle/wrapper/GradleWrapperMain Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Which OS X version and JVM are you using? Do you have a stack trace for the UnsatisfiedLinkError that you were seeing?

OS X version 10.9.2, JVM version

java version “1.6.0_65” Java™ SE Runtime Environment (build 1.6.0_65-b14-462-11M4609) Java HotSpot™ 64-Bit Server VM (build 20.65-b04-462, mixed mode)

  • Exception is: java.lang.UnsatisfiedLinkError: net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.symlink(Ljava/lang/String;Ljava/lang/String;Lnet/rubygrapefruit/platform/internal/FunctionResult;)V

at net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.symlink(Native Method)

at net.rubygrapefruit.platform.internal.DefaultPosixFiles.symlink(DefaultPosixFiles.java:64)

at org.gradle.internal.nativeplatform.filesystem.NativePlatformBackedSymlink.symlink(NativePlatformBackedSymlink.java:33)

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.tryCreateSymbolicLink(GenericFileSystem.java:53)

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.probeCanCreateSymbolicLink(GenericFileSystem.java:121)

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.(GenericFileSystem.java:86)

at org.gradle.internal.nativeplatform.filesystem.FileSystemServices.createFileSystem(FileSystemServices.java:47)

at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)

at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:323)

at org.gradle.internal.service.DefaultServiceRegistry.access$1200(DefaultServiceRegistry.java:53)

at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:636)

at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:592)

at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:434)

at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:474)

at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:295)

at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:279)

at org.gradle.internal.nativeplatform.services.FileSystems.getDefault(FileSystems.java:22)

at org.gradle.initialization.DefaultCommandLineConverter.(DefaultCommandLineConverter.java:64)

at org.gradle.launcher.cli.BuildActionsFactory.(BuildActionsFactory.java:71)

at org.gradle.launcher.cli.CommandLineActionFactory.createActionFactories(CommandLineActionFactory.java:66)

at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:186)

at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)

at org.gradle.launcher.Main.doAction(Main.java:46)

at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)

at org.gradle.launcher.Main.main(Main.java:37)

at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)

at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)

at org.gradle.launcher.GradleMain.main(GradleMain.java:23)

Note: The above was from my most recent attempt at using the non-wrapper version.

Using the wrapper version, all I see is the following:

./gradlew build --stacktrace Exception in thread “main” java.lang.NoClassDefFoundError: org/gradle/wrapper/GradleWrapperMain Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Can you download and run the test app for our native integration at http://repo.gradle.org/gradle/libs-releases-local/net/rubygrapefruit/native-platform-test/0.10/native-platform-test-0.10.zip

This should display some stuff about your machine and display some colored output.

  • JVM: Apple Inc. 1.6.0_65 * OS (JVM): Mac OS X 10.9.2 x86_64 * OS (Kernel): Darwin 13.1.0 x86_64 (amd64) * PID: 53329 * File systems:

  • / -> /dev/disk2 (hfs local)

  • /dev -> devfs (devfs local)

  • /Volumes/Untitled -> /dev/disk1s4 (ntfs local)

  • /net -> map -hosts (autofs remote)

  • /home -> map auto_home (autofs remote)

  • /Volumes/Android Studio 135.1078000 -> /dev/disk3s1 (hfs local)

  • /Volumes/Orpheus Interactive’s Public Fo -> //darrylwright@orpheusmacmini.local/Orpheus%20Interactive`s%20Public%20Fo (afpfs remote)

  • /Volumes/Locker -> //darrylwright@orpheusmacmini.local/Locker (afpfs remote)

  • /Volumes/darrylwright -> //darrylwright@orpheusmacmini.local/darrylwright (afpfs remote) * Stdout: terminal * Stderr: terminal * Terminal implementation: Curses terminal on stdout * Terminal size: 127 cols x 38 rows * Text attributes: yes * Color: yes * Cursor motion: yes

TEXT ATTRIBUTES [normal] [bold] [normal]

COLORS [black] [black] [red] [red] [green] [green] [yellow] [yellow] [blue] [blue] [magenta] [magenta] [cyan] [cyan] [white] [white]

CURSOR MOVEMENT [1]

[2]

[3]

[4]

done!

Thanks for trying the test app. I would have expected it to fail in a similar way as Gradle. Very strange.

Can you run the test app a couple of times with ‘–cache-dir <some-temp-dir>’ (this is closer to how Gradle uses the native integration).

Also perhaps try comparing ‘sum ~/.gradle/native/19/osx-amd64/libnative-platform.dylib’ and ‘sum <some-temp-dir>/19/osx-amd64/libnative-platform.dylib’ and make sure they are the same.

Also, you might try the latest Gradle nightly from http://www.gradle.org/nightly. It doesn’t use the symlink() function any more - so we can see if it’s a problem with the native integration as a whole or just the symlink stuff.

I have the same error. Here is the result of the native platform test.

  • JVM: Sun Microsystems Inc. 1.6.0_45 * OS (JVM): Linux 3.14.0-031400rc5-generic amd64 * OS (Kernel): Linux 3.14.0-031400rc5-generic x86_64 (amd64) * PID: 25527 * File systems:

  • / -> /dev/sda1 (ext4 local)

  • /proc -> proc (proc local)

  • /sys -> sysfs (sysfs local)

  • /sys/fs/cgroup -> none (tmpfs local)

  • /sys/fs/fuse/connections -> none (fusectl local)

  • /sys/kernel/debug -> none (debugfs local)

  • /sys/kernel/security -> none (securityfs local)

  • /dev -> udev (devtmpfs local)

  • /dev/pts -> devpts (devpts local)

  • /tmp -> none (tmpfs local)

  • /run -> tmpfs (tmpfs local)

  • /run/lock -> none (tmpfs local)

  • /run/shm -> none (tmpfs local)

  • /run/user -> none (tmpfs local)

  • /sys/fs/pstore -> none (pstore local)

  • /sys/fs/cgroup/systemd -> systemd (cgroup local)

  • /run/user/1000/gvfs -> gvfsd-fuse (fuse.gvfsd-fuse local) * Stdout: not a terminal * Stderr: not a terminal

BUILD SUCCESSFUL

Total time: 7.412 secs

Thanks for that. which linux distribution are you using?

Ubuntu 14.04 with Gnome shell

Resolved: I had temp mounted as NoExec remount with executable rights fixed the issue

Also seeing this on my Mac. Gradle 1.10 works fine, but I get this issue if I run gradle-1.12 under my user name.

java.lang.UnsatisfiedLinkError: net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.symlink(Ljava/lang/String;Ljava/lang/String;Lnet/rubygrapefruit/platform/internal/FunctionResult;)V >

at net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.symlink(Native Method) >

at net.rubygrapefruit.platform.internal.DefaultPosixFiles.symlink(DefaultPosixFiles.java:64) >

at org.gradle.internal.nativeplatform.filesystem.NativePlatformBackedSymlink.symlink(NativePlatformBackedSymlink.java:33) >

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.tryCreateSymbolicLink(GenericFileSystem.java:53) >

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.probeCanCreateSymbolicLink(GenericFileSystem.java:121) >

at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.(GenericFileSystem.java:86) >

at org.gradle.internal.nativeplatform.filesystem.FileSystemServices.createFileSystem(FileSystemServices.java:47) >

at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)

Running it under ‘sudo’ seems to avoid this problem.

Me too! Using Android Studio 0.8.2 and Android gradle plugin 0.12 and Mac OS 10.9.3.

Running builds using UI controls in Android Studio works. But if I drop into the terminal inside the IDE or outside of it, gradlew throws the above error unless I run everything under sudo.

If I start Android Studio from the command line using sudo ./studio then gradlew commands inside the terminal IDE work but I don’t think this is good practice.

Ok, I fixed my issue. Posting here in case helpful to others. Inside my .gradle in directory in my home folder, the native directory owner was root rather than user. So, rather than trying to chown, I deleted the .gradle directory and had it rebuilt by Android Studio. Now the owner of the native directory inside .gradle is user. This now lets me to run ./gradlew without sudo.

Hi–

This issue just started happening to me this morning after my upgrade to 2.1 – I redownloaded to 2.0 which didn’t resolve the issue, and both the jenkins and root accounts on this server are capable of running fine. Per the comments above, I did chown’s of my files, deleted my ~/.gradle, etc. and I’m still having this problem. It always happens on the jar target, no matter the project. How do I get more info about what its freaking out about? --debug gave me a river but not much useful. Any assistance/tips/thoughts? Thanks!

=== % gradle assemble :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar

FAILURE: Build failed with an exception.

  • What went wrong: net.rubygrapefruit.platform.internal.jni.PosixFileFunctions.chmod(Ljava/lang/String;ILnet/rubygrapefruit/platform/internal/FunctionResult;)V

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED ===