0

I have cloned the project - https://github.com/Microsoft/Partner-Center-Java-Samples/tree/master/secure-app-model/keyvault from GIT to my local Eclipse.

When I run the partnerconsent project on my local server, I am getting this exception :-

class java.util.Collections$SingletonList cannot be cast to class java.lang.String (java.util.Collections$SingletonList and java.lang.String are in module java.base of loader 'bootstrap')

Screenshot for reference

Stack trace

java.lang.ClassCastException: class java.util.Collections$SingletonList cannot be cast to class java.lang.String (java.util.Collections$SingletonList and java.lang.String are in module java.base of loader 'bootstrap')
    at com.nimbusds.oauth2.sdk.util.URLUtils.serializeParameters(URLUtils.java:103)
    at com.microsoft.aad.adal4j.AdalTokenRequest.toOAuthRequest(AdalTokenRequest.java:160)
    at com.microsoft.aad.adal4j.AdalTokenRequest.executeOAuthRequestAndProcessResponse(AdalTokenRequest.java:86)
    at com.microsoft.aad.adal4j.AuthenticationContext.acquireTokenCommon(AuthenticationContext.java:930)
    at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:70)
    at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:38)
    at com.microsoft.aad.adal4j.AdalCallable.call(AdalCallable.java:47)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
ab.it.gcp
  • 151
  • 1
  • 14
  • 2
    Check the logs of your app for the complete stack trace and verify where that cast is happening. You didn't provide enough information to identify the source and no one is going to clone the project and reproduce it like that. It's on you to provide a [mre]. – Joachim Sauer Feb 22 '23 at 12:29
  • @JoachimSauer - Although there is no stack trace in the logs but I have updated the question with the code which seems to be the source. – ab.it.gcp Feb 22 '23 at 13:29
  • 2
    [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551) – Joachim Sauer Feb 22 '23 at 13:36
  • Replaced image with actual code. For error, just wanted to show where I saw the it. Hence, added the image. Hope the code helps in finding the source. – ab.it.gcp Feb 22 '23 at 13:52
  • Since the line you mention doesn't handle `String` or `List`, it can't be the one that actually throws the exception. Did you try adding a catch block for `Exception` and print the full stack trace there? – Joachim Sauer Feb 22 '23 at 13:59
  • Done, I just printed the stack trace in the catch block from where it was redirected to the error JSP. Updated the question with it. Just FYI, all the invocations in the stack trace are from library classes and not directly from project. So, I cannot modify those. – ab.it.gcp Feb 22 '23 at 14:32
  • That stack trace is pretty deep in code that I assume is not yours. That means there's either a bug in the code or it's been misconfigured somehow. I'm don't really know any of the software involved, so I can't give you more specific suggestions. – Joachim Sauer Feb 22 '23 at 14:34
  • Created an issue for this project in GIT because I see that for another GIT project which is also microsoft partner center related, a similar issue had been posted and it was fixed - https://github.com/microsoft/Partner-Center-Java/issues/85 But I'm not able to check what exactly was that fix. – ab.it.gcp Feb 22 '23 at 14:49
  • @ab.it.gcp Did you got this fixed? – Aswin Mar 10 '23 at 11:44
  • @Aswin - No. There's no response on the GIT issue as well. – ab.it.gcp Mar 10 '23 at 11:49

1 Answers1

-1

Java

string str = "A"; // No space character.
(string) str.split(" "); // Error
(ArrayList<string>) str.split(" "); // Error
(List<string>) str.split(" "); // No Error

Kotlin

val str = "A" // No space character.
str.split(" ") as String // Error
str.split(" ") as ArrayList<String> // Error
str.split(" ") as List<String> // No Error