OAuth 2.0

So far, you’ve used App Engine to deploy servlets that respond to GET and POST requests, and you’ve used Datastore to store data.


This is a companion discussion topic for the original entry at https://happycoding.io/tutorials/google-cloud/oauth-2

Hello @Kevin ,

I downloaded your example and trying to run locally. I am getting below error.

java.lang.NullPointerException
at io.happycoding.ServerMain.main (ServerMain.java:29)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
at java.lang.Thread.run (Thread.java:834)

at the line:
URL webAppDir =
ServerMain.class.getClassLoader().getResource(“META-INF/resources”);
webAppContext.setResourceBase(webAppDir.toURI().toString());

Am I missing some Server config?
Thanks,
Ravi

I think this is because the code expects a webapp directory inside the src/main directory. In this example, that directory is empty, but GitHub doesn’t store empty directories.

To fix this, create an empty webapp directory inside the project structure:

oauth2-hello-world/src/main/webapp

Let me know if that works!

Hello @Kevin,

i have the same problem like Ravi and adding the empty webapp directory doesn´t solves it.
Maybe i am doing something wrong.

Thanks,
Maxi

Can you post the exact error message you’re getting?

I have the same error, the problem is that in line 27 of the ServerMain class the URL object is defined as null
URL webAppDir = ServerMain.class.getClassLoader().getResource(“META-INF/resources”);
then the error jump in line 29:
webAppContext.setResourceBase(webAppDir.toURI().toString());