java.lang.NoClassDefFoundError: com/google/api/client/extensions/appengine/auth/oauth2/AbstractAppEngineAuthorizationCodeServlet

1,410 views
Skip to first unread message

Amit Rai

unread,
Feb 27, 2014, 9:49:25 AM2/27/14
to google-a...@googlegroups.com
Hi 

Here I am doing google directory search that will search all the people in same directory using java.
Below is the block of code

public class DirectorySampleServlet
    extends AbstractAppEngineAuthorizationCodeServlet {

  /**
   * Be sure to specify the name of your application. If the application name is {@code null} or
   * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0".
   */
  private static final String APPLICATION_NAME = "";

  private static final long serialVersionUID = 1L;

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {
    // Get the stored credentials using the Authorization Flow
    AuthorizationCodeFlow authFlow = initializeFlow();
    Credential credential = authFlow.loadCredential(getUserId(req));
    // Build the Directory object using the credentials
    @SuppressWarnings("unused")
    Directory admin = new Directory.Builder(
        Utils.HTTP_TRANSPORT, Utils.JSON_FACTORY, credential)
        .setApplicationName(APPLICATION_NAME)
        .build();

    // Add the code to make an API call here.

    // Send the results as the response
    resp.setStatus(200);
    resp.setContentType("text/html");
    PrintWriter writer = resp.getWriter();
    writer.println("Success! Now add code here.");
  }
  @Override
  protected AuthorizationCodeFlow initializeFlow() throws ServletException, IOException {
    return Utils.initializeFlow();
  }

  @Override
  protected String getRedirectUri(HttpServletRequest req) throws ServletException, IOException {
    return Utils.getRedirectUri(req);
  }
}




I have included all the dependency jar file and build path also.And this code is compiled successfully but while running in localhost 
its giving following error.



org.mortbay.util.MultiException[java.lang.NoClassDefFoundError: com/google/api/client/extensions/appengine/auth/oauth2/AbstractAppEngineAuthorizationCodeCallbackServlet, java.lang.NoClassDefFoundError: com/google/api/client/extensions/appengine/auth/oauth2/AbstractAppEngineAuthorizationCodeServlet]
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:656)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:249)
at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:306)
at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26)
at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:79)
at com.google.appengine.tools.development.Modules.startup(Modules.java:88)
at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:254)
at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:212)
at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:210)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:210)
at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:414)
at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
at com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:348)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:324)
java.lang.NoClassDefFoundError: com/google/api/client/extensions/appengine/auth/oauth2/AbstractAppEngineAuthorizationCodeCallbackServlet


Someone please help me regarding this.Thanks in advance



This message and any files transmitted with it are the property of Sigma-Aldrich Corporation, are confidential, and are intended solely for the use of the person or entity to whom this e-mail is addressed. If you are not one of the named recipient(s) or otherwise have reason to believe that you have received this message in error, please contact the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited.

Vinny P

unread,
Feb 28, 2014, 2:45:05 AM2/28/14
to google-a...@googlegroups.com
On Thu, Feb 27, 2014 at 8:49 AM, Amit Rai <amit...@sial.com> wrote:
I have included all the dependency jar file and build path also.And this code is compiled successfully but while running in localhost 
its giving following error.

org.mortbay.util.MultiException[java.lang.NoClassDefFoundError: com/google/api/client/extensions/appengine/auth/oauth2/AbstractAppEngineAuthorizationCodeCallbackServlet, java.lang.NoClassDefFoundError: com/google/api/client/extensions/appengine/auth/oauth2/AbstractAppEngineAuthorizationCodeServlet]



Are you including the JAR dependencies via Maven or by manually placing the library JAR? If you're manually placing the JAR file, where did you originally download the file from? Can you open up the JAR and double check that the "missing" classes are included?
 
 
-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com
 

Amit Rai

unread,
Feb 28, 2014, 3:34:52 AM2/28/14
to google-a...@googlegroups.com
Hi Vinny Thanks for reply,

I am not as much aware with maven.but here wat code I have is using maven only.And I given jar file manually with java build path.
Is it the problem.


Amit Rai / Google Developer
07th Floor,Tower-2, e -City, Electronic City, 1st Phase. 
Bangalore.560100 India 
Extn: 7814, P: (+91) 8050637 782  
E:  amit.rai@sial.com          www.sigmaaldrich.com


--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/W-OV_hvqcYs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Vinny P

unread,
Mar 1, 2014, 1:01:57 AM3/1/14
to google-a...@googlegroups.com
On Fri, Feb 28, 2014 at 2:34 AM, Amit Rai <amit...@sial.com> wrote:
I am not as much aware with maven.but here wat code I have is using maven only.


I would try disconnecting the project from Maven and manually adding the JAR libraries specified in the Maven build to your project/build path. 

Somewhere along the line, the appropriate libraries aren't being bundled into the WAR. You'll have to pin down where in the build process that's happening. The easiest way to check Maven's work is to temporarily bypass it by manually supplying the libraries.

Amit Rai

unread,
Mar 3, 2014, 2:44:53 AM3/3/14
to google-a...@googlegroups.com
Yes I tried this code without maven only there is no compile time error with this while adding manually jar file.
Only problem is when I am running the project.
Might be problem with maven dependancy only


Amit Rai / Google Developer
07th Floor,Tower-2, e -City, Electronic City, 1st Phase. 
Bangalore.560100 India 
Extn: 7814, P: (+91) 8050637 782  
E:  amit.rai@sial.com          www.sigmaaldrich.com


--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/W-OV_hvqcYs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Vinny P

unread,
Mar 4, 2014, 7:22:26 PM3/4/14
to google-a...@googlegroups.com
On Mon, Mar 3, 2014 at 1:44 AM, Amit Rai <amit...@sial.com> wrote:
Yes I tried this code without maven only there is no compile time error with this while adding manually jar file.
Only problem is when I am running the project. Might be problem with maven dependancy only


Does the error occur when running the Maven build, or when running the application after compiling with the manually-included library? 

Which libraries are getting pulled in by Maven? 
Reply all
Reply to author
Forward
0 new messages