Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception in Library.java on file extraction is not reported well #27

Closed
adrian-baker opened this issue Sep 1, 2016 · 0 comments
Closed

Comments

@adrian-baker
Copy link

The stack trace and any nested exception at https://github.com/fusesource/hawtjni/blob/master/hawtjni-runtime/src/main/java/org/fusesource/hawtjni/runtime/Library.java#L304 are discarded, whereas it should be chained to the resulting exception that is thrown, not just the message. In addition the location of the file operation that was attempted should be included.

It's very likely that an exception can occur while trying to extract native libraries. In my case it was because the Karaf client had set the tmp dir to a non-standard location which wasn't readable, but this simple issue took a significant amount of time to track down, because the root exception or file location wasn't reported, only the message. Without the stacktrace, the (surprising) fact that a write was being attempted wasn't apparent either.

Here's the resulting, unhelpful, one liner I started with:

[vagrant@localhost data]$ /opt/karaf/bin/client
Logging in as karaf
391 [sshd-SshClient[4445629]-nio2-thread-2] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /0.0.0.0:8101 presented unverified RSA key: 49:03:6e:ad:91:7d:c2:11:cb:86:84:73:b2:9e:e9:4b
Could not load library. Reasons: [no jansi in java.library.path, Permission denied]

Here's the same error with the verbose flag, with the implication it's a read error, but no indication of where:

[vagrant@localhost java]$ /opt/karaf/bin/client -v
...
java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, Permission denied]
at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
at org.fusesource.jansi.internal.CLibrary.(CLibrary.java:42)
at org.fusesource.jansi.AnsiConsole.wrapOutputStream(AnsiConsole.java:48)
at org.fusesource.jansi.AnsiConsole.(AnsiConsole.java:38)
at org.apache.karaf.client.Main.main(Main.java:214)

My initial thought was a read permissions error, it wasn't until I read Library.java that I realised a write was being attempted, even then it took more time to determine the location was the standard tmp dir.

Besides not swallowing the original exception, when this sort of write IO fails, it would be best to report as much detail about the attempted operation as possible, ie the location that was attempted to be written to.

@gnodet gnodet closed this as completed in f99972b Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant