Got java.lang.NoClassDefFoundError when try to create HTTPRequest object

Issue #242 invalid
henryzhu79 created an issue

Hi,

I try to run the example code of the "Requesting an authorisation code" from the official website in eclipse. https://connect2id.com/products/nimbus-oauth-openid-connect-sdk/examples/openid-connect/oidc-auth

And got an exception when executes the below code. HTTPResponse httpResponse = req.toHTTPRequest().send();

The exception error is below. Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/internet/ParseException at com.nimbusds.oauth2.sdk.AuthorizationRequest.toHTTPRequest(AuthorizationRequest.java:896) at com.nimbusds.oauth2.sdk.AuthorizationRequest.toHTTPRequest(AuthorizationRequest.java:916) at client.openidtest.OpenIdTestMain.auth(OpenIdTestMain.java:72) at client.openidtest.OpenIdTestMain.main(OpenIdTestMain.java:34) Caused by: java.lang.ClassNotFoundException: javax.mail.internet.ParseException 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) ... 4 more

It seems the JVM cannot load the HTTPRequest class. But the class file exists in the jar.

Any idea on how to fix it? Thanks.

Comments (6)

  1. Connect2id OSS

    Is the JAR in your Java CLASSPATH? :)

    If you use Maven to build your project, try mvn clean before.

  2. henryzhu79 reporter

    Thank you for your reply.

    I think the JAR is in the CLASSPATH. The other classes can be loaded without error. For example AuthenticationRequest. And I did not use Maven. Just Eclipse.

    I attached my code. Please help check where the problem is.

  3. Vladimir Dzhuvinov

    Consider setting up Maven or similar build tool in Eclipse to resolve deps automatically.

    Dev work becomes much easier with that :)

  4. Log in to comment