Vonage / vonage-java-sdk

Vonage Server SDK for Java. API support for SMS, Messages, Voice, Text-to-Speech, Numbers, Verify (2FA), Video and more.
https://developer.vonage.com/en/home
Apache License 2.0
96 stars 121 forks source link

new JWTAuthMethod throws "java.lang.NoClassDefFoundError: com/auth0/jwt/JWTSigner" #40

Closed leggetter closed 7 years ago

leggetter commented 7 years ago

With the following code:

Path path = Paths.get(PRIVATE_KEY);
JWTAuthMethod auth = new JWTAuthMethod(APPLICATION_ID, path);

I see the following stacktrace:

Exception in thread "main" java.lang.NoClassDefFoundError: com/auth0/jwt/JWTSigner
    at com.nexmo.client.auth.JWTAuthMethod.<init>(JWTAuthMethod.java:63)
    at com.nexmo.client.auth.JWTAuthMethod.<init>(JWTAuthMethod.java:68)
    at App.main(App.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: com.auth0.jwt.JWTSigner
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 8 more

My build.gradle looks as follows:

// Apply the java plugin to add support for Java
apply plugin: 'java'

apply plugin: 'eclipse'

// Apply the application plugin to add support for building an application
apply plugin: 'application'

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()

    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots/'
    }

    mavenCentral()
}

dependencies {
    // Use JUnit test framework
    testCompile 'junit:junit:4.12'

    compile 'com.nexmo:client:2.0.0-SNAPSHOT'
}

// Define the main class for the application
mainClassName = 'App'

This looks like a dependency hasn't been found. What steps should I undertake to insure this dependency is installed?

leggetter commented 7 years ago

Test code available via https://github.com/nexmo-community/nexmo-java-quickstart/blob/master/src/main/java/App.java

judy2k commented 7 years ago

Created a test environment from nexmo-java-quickstart and ran gradle test - the problem did not occur. I'd suggest that this was maybe an intermittent problem, perhaps a network failure, or something unusual about the affected system.