Could not initialize class com.sun.jna.Native
Asked by flo schramm:

I have a problem with fisheye. When I want to upload a private key, i get the following error in fisheye.out

```
2012-09-10 16:46:51,948 ERROR - Error for /admin/servlet.gupldjava.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native	at com.cenqua.fisheye.util.FileSystemUtils.privatise(FileSystemUtils.java:81)	at com.atlassian.fecru.security.SshKeyManagerImpl.createPrivateKeyFile(SshKeyManagerImpl.java:97)	at com.atlassian.fecru.security.SshKeyManagerImpl.saveKeyPair(SshKeyManagerImpl.java:111)	at com.atlassian.fecru.security.SshKeyManagerImpl.isEncrypted(SshKeyManagerImpl.java:103)	at com.atlassian.fecru.gwt.servlet.GwtSshKeyUploadServlet.executeAction(GwtSshKeyUploadServlet.java:40)	at gwtupload.server.UploadAction.doPost(UploadAction.java:162)
```

What went wrong here?


Answers:
author: Edward Moon
body: I was able to get past the problem like Allan Saddi by upgrading the jna jar to version 3.4.2.

With the old jna jar in place, I would get classdef not found errors if I attempted to upload a public key or test a connection using a FishEye generated key.

You can download the jar file at this URL: <https://github.com/twall/jna/blob/3.4.2/dist/jna.jar?raw=true>

1. Download the file. It will be named jna.jar
2. Rename the jar so you know the version (eg mv jna.jar jna-3.4.2.jar)
3. Shutdown FishEye
4. Remove the old jar: (mv \[FISHEYE_INSTALL\]/lib/jna-3.0.9.jar /some/other/dir
5. Copy the new jar: (cp jna-3.4.2.jar \[FISHEYE_INSTALL\]/lib
6. Start FishEye

At this point I was able to successfully generate a ssh key pair, manually upload the public key to GitHub Enterprise, and add the repository.

comments: author: flo schramm
body: worked like a charm!


author: Geoff Crain
body: Hi flflfl,

The problem is that we are depending on JNA to set permissions on the newly created SSH key, using for example chmod on unix.

The error shows that the class com.sun.jna.Native is failing to load due to a missing dependency.

Potentially this is due to the JVM that you are using. Can you please let us know what OS and JVM versions you are using?

Also, is there any more stack trace that would suggest what dependency is actually missing?

Cheers,

Geoff

comments: author: flo schramm
body: Hi Geoff,

its CentOS 5.8 with jvm: 1.6.0_34, 64Bit. you can find the stacktrace attached (fisheye.log) .

Thanks,  
Flo


author: Benni Weber
body: happens also with ubuntu 64bit,

java version "1.7.0_25"

OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)

OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)  
and Fisheye 3.1.3 with jna-3.4.2.  
any new ideas how to fix this? I want to add a simple git repo :(.


author: Sreram B
body: It also happens in Fedora 17, x86-64 with OpenJDK 1.7.0_09 -icedtea version. However i dont have or use fisheye.

And thanks for the dependency suggession. Worked like charm.


author: Malik
body: Fine. But why does this seem to be only happening with CentOS ??

I am unable to reproduce this with ubuntu...(same FE version, same oracele jvm,....)


author: Malik
body: Fine. But why does this seem to be only happening with CentOS ??

I am unable to reproduce this with ubuntu...(same FE version, same oracele jvm,....)


author: Edward Moon
body: I am having the same issue when trying to upload a private key for a Git repo in FishEye.

This is **NOT** due to a missing library in the JVM. The jna libary is part of the FishEye install. The file is located at \[FishEye install dir\]/lib/jna-3.4.0.jar.

Besides the stack trace, I occasionally get the following in a popup:

An error has occurred {#toc-hId-1676253882}
-------------------------------------------

Error  
Could not save private key: POSIX c library "c" was not found  
Error 2  
Could not save private key: POSIX c library "c" was not found  
You are running release CR2.8.1 FE2.8.1 (20120829051639 2012-08-29), please report your release number when reporting bugs.  
Got a suggestion or an issue?  
Discuss it in [our forums](http://forums.atlassian.com/) or visit our [support website](http://support.atlassian.com/) for other options.

In the logs I see:

INFO: Initiating Jersey application, version 'Jersey: 1.8-atlassian-6 03/12/2012 02:59 PM'

2012-09-13 12:22:13,373 ERROR - Could not save private key: POSIX c library "c" was not found

2012-09-13 12:22:14,250 ERROR - Could not save private key: POSIX c library "c" was not found

FishEye version:

(Version:2.8.1 Build:20120829051639 2012-08-29

Java version:

\[fisheye@fisheye01 lib\]$ java -version

java version "1.6.0_35"

Java(TM) SE Runtime Environment (build 1.6.0_35-b10)

Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode)


author: Allan Saddi
body: Hello,

We ran into this issue as well and found this thread by searching.

I eventually fixed this by upgrading jna-3.4.0.jar in FishEye to jna-3.4.2.jar. It works for us, but YMMV.  
We are using Oracle JDK 1.6.0_35 on RHEL 5, 64-bit. I believe there was a fix to JNA regarding the specific glibc versions used that affect this.


author: JohnA
body: Hi there,

From the looks of the error, there has been an issue importing a library that FishEye is dependent upon so I would suggest checking that you are running your instance on a supported JVM. I'm sorry to say that is just speculation, but certainly something worth investigating.

All the best,  
John

comments: author: flo schramm
body: Hi John,

its Java 1.6.0_34.

Thanks,  
Flo


Tags: class-exception