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.
You could try to copy the whole folder that is created during compiling into your tomcat webapps folder. If that works you would know if the problem lies in creating the war or has a different source. I would assume it has something to do with your web.xml. In your tomcat directory if you look in /webapps/yourproject/WEB-INF/ how does the web.xml look like? Do you have rpcs in your application ? are they working?
you have mapped the servlet as
/stockwatcher/stockPrices
but you are invoking it as:
/stockwatcher/stockPrice?q=ABC
It's a typo.
Make sure that application was started on the same path as it was in eclipse
http://127.0.0.1:8080/stockwatcher
Tomcat uses the war/folder name as a root path by default, so if you have stockwatcher-1.0-SHAPSHOT.war it will be published as http://127.0.0.1:8080/stockwatcher-1.0-SHAPSHOT...
Also to Tomcat Management page http://localhost:8080/manager/html to make sure on which path your application has been published
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