Scala class file error compared to Java jar

I encountered a compilation error:

[warn] Class com.google.api.client.auth.oauth2.Credential not found - continuing with a stub. [error] error while loading GoogleService, class file '....../gdata-core-1.0.jar(com/google/gdata/client/GoogleService.class)' is broken

I found this similar question , but could not successfully use its solution for my case. How can I track what really broke in this jar according to the Scala compiler (i.e. Get information about what is really broken) to make sure that there should be a solution?

The source from where I think this Google banner is built is here .

Note. Unlike other questions, in my case google banners are included in my project in an unmanaged lib directory, in accordance with these instructions for setting up Google .

+1
source share
2 answers

As described in your related answer, this error occurs when a class contains some annotations that are no longer present in the classpath. Java considers this acceptable, but Scala does not. Usually, you encounter this problem with highly optimized java libraries, where they deliberately exclude "unnecessary" annotations. Google does this for a lot of its code; to be completely honest, I don’t think I have ever seen this problem in any libraries other than Google.

The pragmatic solution is to use the advanced search in the maven center to find a jar containing the missing class. If gdata-core was built using maven (since it is currently the most serious java library), it would be easy to see from the <dependencies> pom.xml that was declared optional , and therefore find out where any problems of this class arise. Unfortunately, this particular library is still built using ant, so it’s hard to determine the path to the assembly class without reading the whole build.xml and manually figuring it out.

+1
source

I had to find the jar file provided by google, which contained the class mentioned in the warning ( Credential class), and paste it into the lib directory used by sbt.

With a really large number of heuristics, it turned out to be the jar file google-oauth-client-1.18.0-rc.jar , which I received here and equally exists here , finding out that the source file for which the error was intended simply does not define this class , but rather imports it from another com.google.api.client.auth.oauth2 package. I assume that the last package should be present at compile time, and its compiled class is necessary so that Scala can use the classes contained in the previous jar, at least when Scala is involved.

It’s not entirely accurate how the google build system created all this and how to bind the annotations that made the extra jar required for Scala, but the missing class no longer disappears for Scala.

Hope someone calls back to give a deeper answer on how to bind the details of the broken class to Scala and how to track where to get it without my heuristic search.

0
source

All Articles