Reputation: 13686
I have run into 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 couldn't successfully use its solution for my case. How can I trace what's actually broken in this jar as per the Scala compiler (i.e. get the details of what's actually broken), to make sure what the solution aught to be?
The source where I think this Google jar builds from, is here.
Note: unlike the other questions, in my case, the google jars are included unmanaged in my project, in the lib
directory, as per these google setup instructions.
Upvotes: 1
Views: 2614
Reputation: 17431
As described in your linked answer, this error happens when a class contains some annotations which are no longer present on the classpath. Java considers this acceptable, but Scala does not. You'll generally only run into this problem with heavily optimized java libraries where they've deliberately excluded the "unnecessary" annotations. Google does this for a lot of their code; to be perfectly honest I don't think I've ever seen the problem in any non-google libraries.
The pragmatic solution is to use advanced search on maven central to find the jar that contains the missing class. If gdata-core had been built with maven (as most serious java libraries are these days), it would be easy to see from the <dependencies>
section of pom.xml
which dependencies had been declared optional
, and therefore figure out where any classpath problems of this kind were likely to be. Unfortunately this particular library is still built with ant, so it's hard to determine the build classpath without reading the whole build.xml
and figuring it out "by hand".
Upvotes: 1
Reputation: 13686
Had to find a google supplied jar file where the class mentioned in the warning (class Credential
) is contained, and stick it in my lib
directory used by sbt.
With really a lot of heuristic, it turned out to be the jar file google-oauth-client-1.18.0-rc.jar
which I obtained here and equally exists here, after figuring that the source file that the error is for, simply does not define that class itself but rather imports it from a different package com.google.api.client.auth.oauth2
. I guess the latter package must have been present at compile time, and its compiled class is necessary for Scala being able to use the classes contained in the former jar, at least when Scala is involved.
Not exactly sure how the build system at google produced all of this, and how to pin down the annotations that made the additional jar required for Scala, but the missing class is no longer missing for Scala.
Hope someone would chime in to provide a deeper answer, as to how to pin down the details of a class being broken for scala, and how to trace back where to obtain it sans my heuristic search.
Upvotes: 0