You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ClassNotFoundException when using com.google.gcloud.AuthCredentials in 0.0.9 #260
I tried but I couldn't reproduce your error.
Could you share the complete stacktrace and the code you are using and possibly your pom.xml?
Here is the simple code I tried:
java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at com.google.gcloud.AuthCredentials.__cobertura_init(AuthCredentials.java)
at com.google.gcloud.AuthCredentials.<clinit>(AuthCredentials.java)
at com.acme.prod.core.persist.gce.GCEPersistentStorage.init(GCEPersistentStorage.java:107)
at com.acme.prod.core.persist.gce.GCEPersistentStorage.create(GCEPersistentStorage.java:59)
at com.acme.prod.core.persist.StorageFactory.create(StorageFactory.java:37)
at com.acme.prod.core.persist.StorageFactory.create(StorageFactory.java:28)
at com.acme.prod.app.App.main(App.java:70)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
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)
... 7 more","class":"java.lang.Throwable$WrappedPrintStream
I found a cobertura.properties file in the root of gcloud-java-core-0.0.9.jar
#Generated by maven-cobertura-plugin for project com.google.gcloud:gcloud-java-core:jar:0.0.9
#Fri Oct 09 00:08:23 UTC 2015
net.sourceforge.cobertura.datafile=/home/travis/build/GoogleCloudPlatform/gcloud-java/gcloud-java-core/target/cobertura/cobertura.ser
Decompiling the AuthCredentials class in gcloud-java-core-0.0.9.jar I see:
You are right, I was using a locally installed artifact that does not have that problem.
Must be an issue with our deploy process, cobertura stuff remains in deployed class files. I will look into it, sorry for inconvenient, I'll keep you posted.
This problem seems to have started with 0.0.9. To add some background:
mvn compile compiles classes in target/classes.
mvn cobertura:cobertura instruments classes and places the compiled ones into target/generated-classes/cobertura. In target/generated-classes/cobertura we have class files and a cobertura.properties file.
Looking at the deployed jars it seems that they are being generated from the class files in target/generated-classses/cobertura: they contain cobertura.properties and classes contain cobertura code (see the decompiled AuthCredentails here).
The problem comes from mvn site which (I don't know why) creates the jars for the classes in target/generated-classes/cobertura. The mvn deploy command then deploys these jars.
I think this issue could be solved by replacing the line here with:
Thank you. Please keep me updated about any 0.0.10 release.
We're getting ready to system test a product and I'd rather not run with cobertura instrumented JARs
Since we copy the signing tools into the directory target/travis, those will get erased by clean before they can be used to deploy. As long as we move those to another location, this fix sounds good to me.
java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects
at com.google.gcloud.RetryParams.toString(RetryParams.java:284)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at com.acme.app.core.persist.gce.GCEPersistentStorage.init(GCEPersistentStorage.java:120)
at com.acme.app.core.persist.gce.GCEPersistentStorage.create(GCEPersistentStorage.java:59)
at com.acme.app.core.persist.PersistentStorageFactory.create(PersistentStorageFactory.java:37)
at com.acme.app.core.persist.PersistentStorageFactory.create(PersistentStorageFactory.java:28)
at com.acme.app.app.App.main(App.java:70)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.MoreObjects
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)
... 8 more","class":"java.lang.Throwable$WrappedPrintStream
If the gcloud POM dependencies are correct shouldn't it be included by maven when it resolves all my dependencies?
I have a com.googlecode.objectify dependency in the same project. It holds the dependency on guava 18.0. Not sure why maven chooses objectify as the owner of guava over gcloud...?
When I exclude com.googlecode.objectify from my final target it drops guava... even though gcloud-core has it as a dependency.
Activity
simon-temple commentedon Oct 15, 2015
For now I've added this to my POM but...
mziccard commentedon Oct 15, 2015
I tried but I couldn't reproduce your error.
Could you share the complete stacktrace and the code you are using and possibly your
pom.xml?Here is the simple code I tried:
And the
pom.xmlis:This seems to work here.
simon-temple commentedon Oct 15, 2015
Section of my code:
Part of my POM:
Stack trace:
I found a cobertura.properties file in the root of gcloud-java-core-0.0.9.jar
Decompiling the AuthCredentials class in gcloud-java-core-0.0.9.jar I see:
mziccard commentedon Oct 15, 2015
You are right, I was using a locally installed artifact that does not have that problem.
Must be an issue with our deploy process,
coberturastuff remains in deployed class files. I will look into it, sorry for inconvenient, I'll keep you posted.mziccard commentedon Oct 15, 2015
This problem seems to have started with
0.0.9. To add some background:mvn compilecompiles classes intarget/classes.mvn cobertura:coberturainstruments classes and places the compiled ones intotarget/generated-classes/cobertura. Intarget/generated-classes/coberturawe have class files and acobertura.propertiesfile.Looking at the deployed jars it seems that they are being generated from the class files in
target/generated-classses/cobertura: they containcobertura.propertiesand classes contain cobertura code (see the decompiled AuthCredentails here).The problem comes from
mvn sitewhich (I don't know why) creates the jars for the classes intarget/generated-classes/cobertura. Themvn deploycommand then deploys these jars.I think this issue could be solved by replacing the line here with:
That should delete wrong jars and force building new ones. @ajkannan @aozarov what do you think?
Thanks again to @simon-temple for spotting this!
simon-temple commentedon Oct 15, 2015
Thank you. Please keep me updated about any 0.0.10 release.
We're getting ready to system test a product and I'd rather not run with cobertura instrumented JARs
ajkannan commentedon Oct 15, 2015
Since we copy the signing tools into the directory
target/travis, those will get erased bycleanbefore they can be used to deploy. As long as we move those to another location, this fix sounds good to me.ajkannan commentedon Oct 15, 2015
I'm assigning myself the issue, and I'll test @mziccard's solution.
mziccard commentedon Oct 15, 2015
Thanks @ajkannan, you are right, we might need to move signing tools elsewhere, but that should no be an issue.
mziccard commentedon Oct 15, 2015
@simon-temple We fixed the issue and deployed version 0.0.10!
simon-temple commentedon Oct 16, 2015
Thanks for the quick turnaround.
One other packaging question...
I'm having to add this to my POM:
to avoid this:
If the gcloud POM dependencies are correct shouldn't it be included by maven when it resolves all my dependencies?
mziccard commentedon Oct 16, 2015
guavais not added as a compile dependency in our POMs so maven should be able to resolve it automatically for your project.I tried with the simple setup described previously in #260 (comment):
rm -rf ~/.m2/repository/com/google/guava ~/.m2/repository/com/google/gcloudmvn compilemvn exec:java -Dexec.mainClass="com.mycompany.app.App"At
mvn compileI see guava being downloaded and installed,mvn exec...then runs the app smoothly.simon-temple commentedon Oct 16, 2015
Looks like my problem, sorry.
I have a com.googlecode.objectify dependency in the same project. It holds the dependency on guava 18.0. Not sure why maven chooses objectify as the owner of guava over gcloud...?
When I exclude com.googlecode.objectify from my final target it drops guava... even though gcloud-core has it as a dependency.
...any way. My bad and thanks for looking.
26 remaining items
chore(main): release 2.2.8 (#270)
chore(deps): update dependency com.google.cloud:google-cloud-filestor…
chore(java): add a note in README for migrated split repos (googleapi…
chore(java): add a note in README for migrated split repos (googleapi…
build(java): use yoshi-approver token for auto-approve (#260)
chore: release 0.119.0 (#260)
chore: release 1.105.2-SNAPSHOT (#260)
chore: fix license on token verifier classes (#461)
build(java): use yoshi-approver token for auto-approve (googleapis#260)
chore: fix license on token verifier classes (#461)
deps: update dependency com.google.cloud:google-cloud-spanner-bom to …
deps: update dependency com.google.cloud:google-cloud-shared-dependen…
chore: release 0.122.0 (#277)
deps: update dependency com.google.cloud:google-cloud-shared-dependen…
chore: release 0.122.0 (#277)