Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from 1.25.0 to 1.26.0 causes NoClassDefFoundError on 'Preconditions' #502

Closed
geri-m opened this issue Oct 21, 2018 · 4 comments · Fixed by #508
Closed

Update from 1.25.0 to 1.26.0 causes NoClassDefFoundError on 'Preconditions' #502

geri-m opened this issue Oct 21, 2018 · 4 comments · Fixed by #508
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@geri-m
Copy link
Contributor

geri-m commented Oct 21, 2018

Environment details

  • OS: OSX 10.12.6
  • Java version: 1.8.0_111-b14, 64 bit
  • google-http-java-client version: 1.25.0/1.26.0

Steps to reproduce

  1. The Statement Preconditions.checkState(true); works fine in 1.25.0.
  2. Then switch to Version 1.26.0.
  3. Now you will get a NoClassDefFoundError
  4. Then add guava (version 20.0) and everything is good again.

Stacktrace

java.lang.NoClassDefFoundError: com/google/common/base/Preconditions

	at com.google.api.client.util.Preconditions.checkState(Preconditions.java:81)
	at org.soundtouch4j.ZoneApiTest.testPrecondition(ZoneApiTest.java:172)
	at java.util.ArrayList.forEach(ArrayList.java:1249)
	at java.util.ArrayList.forEach(ArrayList.java:1249)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Preconditions
	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)
	... 41 more

Any additional information below

Making sure to follow these steps will guarantee the quickest resolution possible.

In the class Preconditions there is a change from com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(expression); to com.google.common.base.Preconditions.checkArgument(expression); . And this package is not part of the JAR File.

@chingor13 chingor13 added the type: question Request for information or clarification. Not an issue. label Oct 22, 2018
@chingor13
Copy link
Collaborator

Guava has been a "provided" dependency for a long time, meaning that it's up to you to add a dependency (or be using another library with a guava dependency). This library supports guava 20+.

That said, we are looking at possibly setting up dependency ranges for these libraries (google-http-java-client, google-oauth-java-client, and google-api-java-client).

@JustinBeckwith JustinBeckwith added triage me I really want to be triaged. and removed triage me I really want to be triaged. labels Oct 22, 2018
@JustinBeckwith JustinBeckwith added triage me I really want to be triaged. and removed triage me I really want to be triaged. labels Oct 22, 2018
@elharo
Copy link
Contributor

elharo commented Oct 31, 2018

  1. Please do not use version ranges for reasons elaborated in https://github.com/GoogleCloudPlatform/cloud-opensource-java/blob/master/library-best-practices/JLBP-14.md

  2. Guava doesn't fit the use case of a provided dependency. It should be explicit.

@elharo elharo mentioned this issue Oct 31, 2018
2 tasks
@garrettjonesgoogle
Copy link
Member

@ejona86 might have context on why Guava is a provided dependency - do the original reasons for it still hold? With Guava's higher surface stability these days, I suspect the situation is different now.

@ejona86
Copy link
Contributor

ejona86 commented Oct 31, 2018

That's because Guava isn't actually a dependency at this level. It looks like it is supposed to be jarjar'd: https://github.com/googleapis/google-http-java-client/blob/master/google-http-client/pom.xml#L44

That said, I do remember that guava was an actual dependency somewhere (maybe oauth?), because of all the guava-jdk5 nastiness, but I don't remember precisely where.

clundin25 pushed a commit to clundin25/google-http-java-client that referenced this issue Aug 11, 2022
This has not be used for years.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants