Got java.lang.NoClassDefFoundError when try to create HTTPRequest object
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)
-
-
reporter - attached OpenIdTest.zip
-
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.
-
- changed status to invalid
You're missing a dependency / JAR to javax/mail/internet/ParseException.
If you use Maven this JAR dependency will be automatically resolved.
http://search.maven.org/#artifactdetails%7Cjavax.mail%7Cmail%7C1.4.7%7Cjar
-
reporter Thanks a lot. :) The problem is resolved.
-
Consider setting up Maven or similar build tool in Eclipse to resolve deps automatically.
Dev work becomes much easier with that :)
- Log in to comment
Is the JAR in your Java CLASSPATH? :)
If you use Maven to build your project, try
mvn clean
before.