GoogleCloudPlatform / java-docs-samples

Java and Kotlin Code samples used on cloud.google.com
https://cloud.google.com/java
Apache License 2.0
1.75k stars 2.82k forks source link

403 on firebase-tictactoe example when trying first move #691

Closed nczempin closed 5 years ago

nczempin commented 7 years ago

In which file did you encounter the issue?

example project at /appengine/firebase-tictactoe

Did you change the file? If so, how?

I changed firebase_config.jspf to the code from the firebase console, as instructed.

Describe the issue

In the example /appengine/firebase-tictactoe, I cannot play a game, because when I click on any of the starting player's empty squares, the request POST http://localhost:8080/move?gameKey=a3620663-5581-4ec5-8b63-0d955e458e0f receives a 403 (Forbidden) result:

send @ jquery.min.js:4
ajax @ jquery.min.js:4
r.(anonymous function) @ jquery.min.js:4
moveInSquare @ main.js:92
dispatch @ jquery.min.js:3
q.handle @ jquery.min.js:3
jquery.min.js:4

I can see some data for players in the firebase console.

My development machine is on Ubuntu-16.04.

I managed to get everything set up and can run "mvn appengine:run". All the tests pass, and the server starts up.

Upon calling localhost:8080, initially I got some errors about missing WEB-INF/view/firebase_config.jspf, which I resolved by manually copying that file to my target/appengine-firebase-tictactoe-1.0-SNAPSHOT/WEB-INF/view folder (from the one in src/). That is probably a separate issue, currently not my concern since I have the workaround. `java.lang.RuntimeException: java.io.FileNotFoundException: WEB-INF/view/firebase_config.jspf (No such file or directory) at com.example.appengine.firetactoe.FirebaseChannel.(FirebaseChannel.java:98) at com.example.appengine.firetactoe.FirebaseChannel.getInstance(FirebaseChannel.java:72) at com.example.appengine.firetactoe.Game.sendUpdateToUser(Game.java:124) at com.example.appengine.firetactoe.Game.sendUpdateToClients(Game.java:130) at com.example.appengine.firetactoe.TicTacToeServlet.doGet(TicTacToeServlet.java:87) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)`

I also see some warnings about directories: [INFO] GCLOUD: WARNING: Your working directory, (/home/nczempin/git/java-docs-samples/appengine/firebase-tictactoe) is not equal to your [INFO] GCLOUD: web application root (/home/nczempin/git/java-docs-samples/appengine/firebase-tictactoe/target/appengine-firebase-tictactoe-1.0-SNAPSHOT) [INFO] GCLOUD: You will not be able to access files from your working directory on the production server. I am not sure if these are relevant to the issue at hand.

nczempin commented 7 years ago

I was able to reproduce this on a Windows 10 machine.

When using the GCloud shell there, the had to be moved to a different directory, to WEB-INF/view directly under the one that has the pom.xml (firebase-tictactoe)

kurtisvg commented 5 years ago

Notice: this issue has been closed because it has been inactive for 732 days. You may reopen this issue if it has been closed in error.