OK, not to beat a dead horse here but I used tcpdump to watch the
traffic going back and forth between my java program and the jetty
server. So here's what my java sends:
GET /bumbleverse/load/object HTTP/1.1
User-Agent: Java/1.6.0_17
Host: localhost:
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
The server responds:
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=iso-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1388
Server: Jetty(6.1.x)
[redacted error message in html that says NOT FOUND]
...
OK fine so you're thinking, well he must have the URL wrong. Well, I
opened up good old telnet and pasted in the headers that the java
program had sent (just cut and paste out of the terminal).
>telnet localhost
Connected to localhost.
Escape character is '^]'.
GET /bumbleverse/load/object HTTP/1.1
User-Agent: Java/1.6.0_17
Host: localhost:
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
HTTP/1.1 200 OK
Content-Type: text/plain; charset=iso-8859-1
Content-Length: 101
Server: Jetty(6.1.x)
[followed by the expected text output]
Thanks for any help/ideas...
Matt
On Apr 12, 9:33 pm, "matt.rosencrantz"
wrote:
> As a fallback I've created a Java version of my uploader. I'm
> basically doing:
> URL url = new
> URL("http://localhost:/load/object";);
> URLConnection con = url.openConnection();
> con.setDoOutput(true);
> con.setDoInput(true);
>
> con.connect();
>
> OutputStreamWriter out =
> new OutputStreamWriter(con.getOutputStream());
> out.write("key=value");
> out.close();
>
> InputStream is = con.getInputStream();
> result = IOUtils.toString(is);
> is.close();
>
> However, the line "InputStream is = con.getInputStream();" produces a
> FileNotFound exception. Some research turned up that this is probably
> because the server is giving back a 404. I can load the exact same
> URL in the browser and it works fine. Is there a way to get low level
> (apache style) request logs for the dev server? My servlet isn't
> seeing anything.
>
> Thanks for any help,
> Matt
>
> On Apr 12, 12:58 pm, "matt.rosencrantz"
> wrote:
>
>
>
> > Hello,
>
> > I am trying to build a very simple data loading python script for my
> > Java servlet based appengine app. Unfortunately python can't seem to
> > open an URL from appengine (or the development server anyway). If you
> > just start with the eclipse appengine project template (call the
> > project fetchtest) then a single servlet will be generated like:
>
> > import java.io.IOException;
> > import javax.servlet.http.*;
>
> > @SuppressWarnings("serial")
> > public class FetchTestServlet extends HttpServlet {
> > public void doGet(HttpServletRequest req, HttpServletResponse resp)
> > throws IOException {
> > resp.setContentType("text/plain");
> > resp.getWriter().println("Hello, world");
> > }
>
> > }
>
> > It will serve by default on: http://localhost:/fetchtest
>
> > I then write the python script:
>
> > import urllib2
> > import sys
> > import time
>
> > for i in range(10):
> > try:
> > print urllib2.urlopen('http://localhost:/
> > fetchtest').read()
> > except:
> > print "Unexpected error:", sys.exc_info()
>
> > time.sleep(1)
>
> > Well, the first time in the python loop the fetch succeeds, but fails
> > after that. In fact if I run the script again all the calls will
> > fail. It only ever works the first time I load the URL after
> > restarting the server. In fact if I load the url in a browser once
> > then the script fails on even the first loop iteration. The python
> > output looks like:
>
> > >python ../util/test.py
>
> > Hello, world
>
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
> > Unexpected error: (, error(54, 'Connection reset
> > by peer'), )
>
> > I've tried catching all exceptions and inspecting what state I know
> > how to on the server side, but it seems like there is no error at all
> > in the servlet. I've tried carefully reading and closing all the
> > different input and output streams in the request and res