Anybody else having problems trying to use com.google.api.services.plus?

973 views
Skip to first unread message

Jon Andrews

unread,
Dec 31, 2011, 4:33:21 AM12/31/11
to google-api-...@googlegroups.com
Anybody got any ideas why I'm getting class not found errors when trying to use com.google.api.services.plus?

I'm using the google-api-services-plus-v1-1.3.0-beta.jar

...Which is included in the google-api-java-client-1.6.0-beta.zip. All the other classes from that zip seem to build ok.

My project is a non Maven project btw.


Uncaught exception from servlet
java.lang.NoClassDefFoundError: com/google/api/services/plus/Plus

Maybe I'm missing some dependencies? Any suggestions greatly appreciated!

Davy

unread,
Dec 31, 2011, 11:25:55 AM12/31/11
to google-api-...@googlegroups.com
Hi,

The NoClassDefFoundError on the Plus.class usually means that it found the Plus.class on your classpath, but it was unable to load it due to the fact that a dependency in the Plus.class was not available in your classpath. (ex: Plus.class importing another class that is not available in the classloader).

Usually the cause of a NoClassDefFoundError is a ClassNotFoundException pointing to the real class that is missing.

Do you have a full stacktrace (including the cause), and can you dump all the JAR files names that are packaged with your app ? 

Jon Andrews

unread,
Dec 31, 2011, 12:04:40 PM12/31/11
to google-api-...@googlegroups.com
Hey Davy,

Many thanks for the response!

Thought it might be a dependency but wasn't sure what I was missing...

In terms of the jars, I'm only using all the ones bundled up in this zip file (which has all the dependencies in a directory):
http://google-api-java-client.googlecode.com/files/google-api-java-client-1.6.0-beta.zip

And lastly this Google+ jar from here.
http://code.google.com/p/google-api-java-client/wiki/APIs#Google+_API

I'm not using any other jars other than these.

Stack trace:

Uncaught exception from servlet
java.lang.NoClassDefFoundError: com/google/api/services/plus/Plus
	at myproject.OAuth2Servlet.doGet(OAuth2Servlet.java:108)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
	at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
	at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
	at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
	at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:422)
	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
	at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
	at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.ClassNotFoundException: com.google.api.services.plus.Plus
	at com.google.appengine.runtime.Request.process-dbbbec814e10fd87(Request.java)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
	at myproject.OAuth2Servlet.doGet(OAuth2Servlet.java:108)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
	... 1 more

Jon Andrews

unread,
Dec 31, 2011, 2:44:08 PM12/31/11
to google-api-...@googlegroups.com
...btw the line from my code that's causing the exception is when I try and create a Plus object:

Either one of these methods seems to do it.

Plus unauthenticatedPlus = new Plus(httpTransport, jacksonFactory);
     
Plus authenticatedPlus = Plus.builder(httpTransport, jacksonFactory)
                .setHttpRequestInitializer(requestInitializer)
                .build();

...also, I've been digging further and I seem to have issues using the GsonFactory classes in the google-plus-java-starter example which leaves me to wonder whether there's a clue there somewhere as to what my problem is:
http://google-plus-java-starter.googlecode.com/files/google-plus-java-starter_v4.zip

This example from Google uses a GsonFactory in OAuth2Servlet to generate the AccessTokenResponse (below) but I get errors when I use this, unless I change it to a JacksonFactory object:

AccessTokenResponse accessTokenResponse = new GoogleAccessTokenRequest.GoogleAuthorizationCodeGrant(
              new NetHttpTransport(),
              new GsonFactory(),
              ConfigHelper.CLIENT_ID,
              ConfigHelper.CLIENT_SECRET,
              code,
              ConfigHelper.REDIRECT_URI
      ).execute();

Anybody know anything about Gson problems/dependencies?

Thanks in advance....

karim duran

unread,
Jan 4, 2012, 5:07:15 PM1/4/12
to google-api-...@googlegroups.com
Hi Jon,

I didn't meet any problem like you describe.

What i can tell you is that in WEB-INF/lib i have gson et jackson too.
But i have a lot of others dependency jar :

karim@innobureau:~/transmission/google-plus-java-webapp-starter-1.0.0/WEB-INF/lib$
ls -l > jon_show_jar.txt

-rw-r--r-- 1 karim karim 1034049 2011-09-16 18:47 ant-1.6.5.jar
-rw-r--r-- 1 karim karim    5752 2011-09-16 18:47 ant-antlr-1.7.1.jar
-rw-r--r-- 1 karim karim   46725 2011-09-16 18:47 commons-codec-1.3.jar
-rw-r--r-- 1 karim karim   60686 2011-09-16 18:47 commons-logging-1.1.1.jar
-rw-r--r-- 1 karim karim 3566844 2011-09-16 18:47 core-3.1.1.jar
-rw-r--r-- 1 karim karim   13468 2011-09-16 18:47 geronimo-spec-jta-1.0.1B-rc4.jar
-rw-r--r-- 1 karim karim   44654 2011-09-16 18:47 google-api-client-1.5.0-beta.jar
-rw-r--r-- 1 karim karim  196915 2011-09-16 18:47 google-http-client-1.5.0-beta.jar
-rw-r--r-- 1 karim karim   34393 2011-09-16 18:47 google-oauth-client-1.5.0-beta.jar
-rw-r--r-- 1 karim karim  164984 2011-09-16 18:47 gson-1.6.jar
-rw-r--r-- 1 karim karim 1143921 2011-09-16 18:47 guava-r09.jar
-rw-r--r-- 1 karim karim  292893 2011-09-16 18:47 httpclient-4.0.3.jar
-rw-r--r-- 1 karim karim  172888 2011-09-16 18:47 httpcore-4.0.1.jar
-rw-r--r-- 1 karim karim  201086 2011-09-16 18:47 jackson-core-asl-1.6.7.jar
-rw-r--r-- 1 karim karim  516429 2011-09-16 18:47 jetty-6.1.14.jar
-rw-r--r-- 1 karim karim   65006 2011-09-16 18:47 jetty-plus-6.1.14.jar
-rw-r--r-- 1 karim karim  163121 2011-09-16 18:47 jetty-util-6.1.14.jar
-rw-r--r-- 1 karim karim 1024680 2011-09-16 18:47 jsp-2.1-6.1.14.jar
-rw-r--r-- 1 karim karim  134910 2011-09-16 18:47 jsp-api-2.1-6.1.14.jar
-rw-r--r-- 1 karim karim   33015 2011-09-16 18:47 jsr305-1.3.9.jar
-rw-r--r-- 1 karim karim  237344 2011-09-16 18:47 junit-4.8.2.jar
-rw-r--r-- 1 karim karim  320306 2011-09-16 18:47 protobuf-java-2.2.0.jar
-rw-r--r-- 1 karim karim  132368 2011-09-16 18:47 servlet-api-2.5-6.1.14.jar
-rw-r--r-- 1 karim karim  120069 2011-09-16 18:47 xpp3-1.1.4c.jar

I didn't configure OAuth as you did with your servlet, but by using the propertie file provided by Google. This file is in the class folder ( WEB-INF/classes/config.properties ).

Config your APPID and APPSECRET you got from API Console and the redirect url(s) ->

I used Maven to deploy the application because deploying manually as you did might generate versionning dependencies recursive problems.

Why don't you use Maven ? It's so simple.

I hope it helps.

Regards.

Karim Duran



2011/12/31 Jon Andrews <mrjona...@gmail.com>

Jon Andrews

unread,
Jan 7, 2012, 4:40:12 AM1/7/12
to google-api-java-client
Haha!

Thanks for your reply Karim - I just realized what my problem is...

I've been running my project on App Engine and it sandboxes some of
the Gson functionality like File IO streams.

Instead of using the compiled Gson jars, I downloaded the source and
commented out any offending methods that used IO and boom, back in the
game!

Thanks for all your help.

Jon
> oauth_redirect_uri =http://localhost:8080/oauth2callback
>
> I used Maven to deploy the application because deploying manually as you
> did might generate versionning dependencies recursive problems.
>
> Why don't you use Maven ? It's so simple.
>
> I hope it helps.
>
> Regards.
>
> Karim Duran
>
> 2011/12/31 Jon Andrews <mrjonandr...@gmail.com>
>
>
>
>
>
>
>
> > ...btw the line from my code that's causing the exception is when I try
> > and create a Plus object:
>
> > Either one of these methods seems to do it.
>
> > Plus unauthenticatedPlus = new Plus(httpTransport, jacksonFactory);
>
> > Plus authenticatedPlus = Plus.builder(httpTransport, jacksonFactory)
> >                 .setHttpRequestInitializer(requestInitializer)
> >                 .build();
>
> > ...also, I've been digging further and I seem to have issues using the
> > GsonFactory classes in the google-plus-java-starter example which leaves me
> > to wonder whether there's a clue there somewhere as to what my problem is:
>
> >http://google-plus-java-starter.googlecode.com/files/google-plus-java...
Reply all
Reply to author
Forward
0 new messages