On Friday, August 16, 2013 3:49:36 PM UTC-4, Bob Flavin wrote: > > > I get *NoClassDefFoundError* when trying to use a class like > com/google/api/client/googleapis/auth/oauth2/GoogleClientSecrets. I'm > trying to use the Java Google Drive library in my GAE servlet. I tested > the code in a standalone java app and with works. The java code compiles > without complaint in Eclipse But when I try to run the servlet in the > 'localhost' server in Eclipse, I get the NoClassDefFoundError. > GoogleClientSecrets (just a convenient, arbitrary class to test on) is in > *com.google.api.client.googleapis.auth.oauth2* in C:\app\gDrive\libs\* > google-api-client-1.16.0-rc.jar* on my system. It appears in the > 'Referenced Libraries for the project. Its in the Java Build Path as an > external jar, (The jar is 'check' marked in the Order and Export tab of > Eclipse Java Build Path dialog -- I think that means include this jar in > the WAR file for the server. > > The fact that Eclipse doesn't see an error when I refer to > GoogleClientSecrets means to me that the Build Path has the class in it. > There must be something I don't understand about the class loader > environment for the 'localhost' 'server', or for the class loader for the > servlet -- that is not finding the google-api-client-1.16.0-rc.jar. (The > server starts fine, but when the servlet loads (when the first HTTP request > is handled) I get the NoClassDefFoundError. > > *Are there any restrictions about classes or jars that GAE loads? Is > there something different about the way the server/servlet class loader > works?* >
----------------------------- Resolved After lots of searching, I found that I was using the wrong jar, that's why it couldn't be found. Vinny P is right that the jars should be in <project>/war/WEB-INF/lib directory. Notably that the normal eclipse class loading mechanism (using 'Build Path') is not what is used by the development app server (or the production server) to find classes -- that is what is used to load the app server, not what the app server uses to load 'isolated' apps.) This page: http://stackoverflow.com/questions/18281420/why-do-i-get-a-noclassdeffounderror-trying-to-use-google-drive-in-gae-in-java-in describes what I learned about the loading process why which the app server finds app classes. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-appengine. For more options, visit https://groups.google.com/groups/opt_out.
