I’ve been following the tutorial on building a sample GWT Application: http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html
I then wanted to try exposing a servlet for serving up some JSON data according to this tutorial: http://code.google.com/webtoolkit/doc/latest/tutorial/JSON.html
Both tutorials are very clear and I had no issues getting it to work in Eclipse running in development mode. The way I’m testing it is by going to this URL: http://localhost:8888/stockwatcher/stockPrices?q=ABC+DEF That returns json results just as is designed in the tutorial. But now I want to deploy this project as a war file and run it in my own Tomcat server. I found this tutorial for deploying turning the project into a .war file: http://blog.elitecoderz.net/gwt-and-tomcat-create-war-using-eclipse-to-deploy-war-on-tomcat/2009/12/. It was clear, and the .war file built without any errors, but after I deploy it, my servlet for JSON data does not work. I simply get a 404 page and nothing happens. I also don’t see anything in the server.log. Also, I am attempting to deploy this in Tomcat 6, if that makes any difference.
I figured it out; it was a problem with the url-pattern tag in my web.xml file.
This is what I had:
but this resulted in the stockPrices servlet being accessible from this URL: http://127.0.0.1:8080/stockwatcher/stockwatcher/stockPrices?q=ABC
Instead, I changed it to:
Because it’s already within the stockwatcher war context.
Now this link works as expected: http://127.0.0.1:8080/stockwatcher/stockPrices?q=ABC