Google API AuthorizationCodeFlow



我真的很难让一个简单的Google OAuth交易进行。我正在使用Java EE,并在JBoss v7.1上运行,并在Eclipse Indigo中对其进行编程。

这是代码。它所做的只是在你访问/index 时运行 servlet,它应该建立一个 AuthorisationCodeFlow。它没有;代码挂起(上传到服务器时)

    privateAuthorizationCodeFlow flow;

.

    package com.pjm.servlets;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.google.api.client.auth.oauth2.AuthorizationCodeFlow;
    @WebServlet("/index")
    public class IndexController extends HttpServlet {          
        private static final String clientId = "1234.apps.googleusercontent.com";
        private static final String clientSecret = "12345abcde";
        private static final String callbackUrl = "http://localhost:8080/ProjectA/callback";
        private AuthorizationCodeFlow flow;
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {       
            String url =        flow.newAuthorizationUrl().setState("xyz").setRedirectUri("https://client.example.com/rd").build();
        }

以下是异常日志的简短版本:

    EXCEPTION
    javax.servlet.ServletException: Servlet execution threw an exception
    ROOT CAUSE
    java.lang.NoClassDefFoundError: com/google/api/client/auth/oauth2/AuthorizationCodeFlow
    com.pjm.servlets.IndexController.doGet(IndexController.java:30)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    ROOT CAUSE
    java.lang.ClassNotFoundException: com.google.api.client.auth.oauth2.AuthorizationCodeFlow from [Module "deployment.PmWebProjectB.war:main" from Service Module Loader]
    org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
    org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)           org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    com.pjm.servlets.IndexController.doGet(IndexController.java:30)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

看起来我没有将正确的 jar 文件上传到正确的位置,但我已经完成了通常的操作并将它们上传到 Eclipse 中,这似乎很高兴。任何建议将不胜感激!

你的罐子在 jboss 上不可用。您如何通过 eclipse 将应用程序部署到 jboss 或将项目导出为 jar(如果是,那么您需要在创建战争时添加 jar)?

相关内容

  • 没有找到相关文章

最新更新