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

java.lang.NoClassDefFoundError exception #31

Open
Koshak118 opened this issue Jan 31, 2019 · 5 comments
Open

java.lang.NoClassDefFoundError exception #31

Koshak118 opened this issue Jan 31, 2019 · 5 comments

Comments

@Koshak118
Copy link

Koshak118 commented Jan 31, 2019

Hi

Thanks for this great wrapper, first of all

The issue I've been messing around in a last couple of days is the exception mentioned in the subject, which is thrown in runtime. The trivial things like playing dependencies definitions and their scopes in pom.xml did not help, the local maven repositories and paths seem to be OK.
The stack is as the following:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class ```
com.squareup.jnagmp.LibGmp
	at com.squareup.jnagmp.Gmp.<init>(Gmp.java:175)
	at com.squareup.jnagmp.Gmp.<init>(Gmp.java:33)
	at com.squareup.jnagmp.Gmp$1.initialValue(Gmp.java:133)
	at com.squareup.jnagmp.Gmp$1.initialValue(Gmp.java:131)
	at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:180)
	at java.lang.ThreadLocal.get(ThreadLocal.java:170)
	at com.squareup.jnagmp.Gmp.modPowInsecure(Gmp.java:95)

The relevant pom.xml section:

<dependencies>
		<dependency>
			<groupId>com.squareup.jnagmp</groupId>
			<artifactId>jnagmp</artifactId>
			<version>2.1.0</version>
		</dependency>
..........
		<dependency>
			<groupId>com.squareup.jnagmp</groupId>
			<artifactId>bouncycastle-rsa</artifactId>
			<version>2.1.0</version>
		</dependency>
</dependencies>

Any ideas?

Thanks

@dragonsinth
Copy link
Collaborator

@Koshak118 I think this exception generally means that the target class failed to initialize properly-- ie its static initializer(s) threw an exception. But I would have expected to see more information in the stack trace, or a separate exception trace detailing why LibGmp failed to load.

@Koshak118
Copy link
Author

Koshak118 commented Feb 3, 2019

Hi @dragonsinth

Thanks for the fast answer. The following is the more comprehensive stack trace with my own code wiped out (I am working under NDA and cannot disclose the exact functionality which uses your library). Generally the logic is trying to make a "multiply" operation in homomorphic encryption algorithm which includes "mod" operation as well

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.squareup.jnagmp.LibGmp
	at com.squareup.jnagmp.Gmp.<init>(Gmp.java:175)
	at com.squareup.jnagmp.Gmp.<init>(Gmp.java:33)
	at com.squareup.jnagmp.Gmp$1.initialValue(Gmp.java:133)
	at com.squareup.jnagmp.Gmp$1.initialValue(Gmp.java:131)
	at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:180)
	at java.lang.ThreadLocal.get(ThreadLocal.java:170)
	at com.squareup.jnagmp.Gmp.modPowInsecure(Gmp.java:95)
	at ********************************************************************
	at ********************************************************************
	at ********************************************************************
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:545)
	at java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
	at java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:438)
	at *******************************************************************************

@dragonsinth
Copy link
Collaborator

@Koshak118 are you on the latest version? Those line numbers make no sense based on the current source code I'm looking at.

@Koshak118
Copy link
Author

Hi @dragonsinth

Sorry for the delayed answer, was with a limited access to the internet for a couple of days

Upgrading the code to the latest version didn't fix a crash; what did fix it is trying to run the code on Mac rather than on Windows, so it looks like it was an environment setup issue

As far as I am concerned you can close the issue

Thanks for the assistance

@dragonsinth
Copy link
Collaborator

Ah, yes. We don't provide a pre-built binary libgmp for Windows. You'd need to build libgmp yourself.

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

2 participants