As a fallback I've created a Java version of my uploader. I'm
basically doing:
URL url = new URL("http://localhost:8888/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" <[email protected]>
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:8888/fetchtest
>
> I then write the python script:
>
> import urllib2
> import sys
> import time
>
> for i in range(10):
> try:
> print urllib2.urlopen('http://localhost:8888/
> 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: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x101044560>)
> Unexpected error: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x1010447e8>)
> Unexpected error: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x1010444d0>)
> Unexpected error: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x101044758>)
> Unexpected error: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x101044560>)
> Unexpected error: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x1010447e8>)
> Unexpected error: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x1010444d0>)
> Unexpected error: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x101044758>)
> Unexpected error: (<class 'socket.error'>, error(54, 'Connection reset
> by peer'), <traceback object at 0x101044560>)
>
> 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 response objects
> to no avail. Can anyone help me debug why this doesn't work? I
> really don't know where to look.
>
> Thanks,
> Matt
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.