我跟着步驟部署DrEdit爲Java:谷歌DrEdit例如對Java將無法正常工作
https://github.com/googledrive/dredit/tree/master/java
當我訪問應用程序,我在AppEngine上的日誌控制檯得到這個錯誤!
2013-10-02 12:51:08.404
/start
java.lang.NullPointerException
at com.google.drive.samples.dredit.DrEditServlet.loginIfRequired(DrEditServlet.java:149)
at com.google.drive.samples.dredit.StartPageServlet.doGet(StartPageServlet.java:46)
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)
這是第149行。credentialManager爲空。
protected void loginIfRequired(HttpServletRequest req,
HttpServletResponse resp) {
Credential credential = getCredential(req, resp);
if (credential == null) {
// redirect to authorization url
try {
resp.sendRedirect(credentialManager.getAuthorizationUrl()); // line 149
它應該在的init()進行設置
public void init() throws ServletException {
super.init();
// init credential manager
credentialManager = new CredentialManager(
getClientSecrets(), TRANSPORT, JSON_FACTORY);
}
我無法使用的System.out.println,因爲它永遠不會在日誌中顯示,即使我選擇了「所有請求」 。
我也越來越的NoSuchMethodError:
Error for/
java.lang.NoSuchMethodError: com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.load(Lcom/google/api/client/json/JsonFactory;Ljava/io/InputStream;)Lcom/google/api/client/googleapis/auth/oauth2/GoogleClientSecrets;
at com.google.drive.samples.dredit.DrEditServlet.getClientSecrets(DrEditServlet.java:249)
at com.google.drive.samples.dredit.DrEditServlet.init(DrEditServlet.java:88)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
這恰好是該行:
249 return GoogleClientSecrets.load(JSON_FACTORY, stream);
我應該指出,它的工作原理確定本地當我訪問本地主機:8888 /啓動,它只是發送給Google進行身份驗證,但當它嘗試重定向到appspot.com/oauth2callback時當然失敗。