[google-appengine] Re: implementing asynchronous http in java
problem solved. I was referencing the app engine/gwt project from a console app. apparently you can't do this. when I debug it as a google app project, it works. hope this minor pain and lesson will help someone else someday. thanks, David On Feb 19, 2:13 pm, davidnelson wrote: > more info, I tried using the app engine version 1.3.0 and that's when > I get nullpointerexceptions. switching back to 1.3.1 and I get the > first exception I initially posted, sync or async. > > On Feb 19, 1:37 pm, Eli Jones wrote: > > > > > I don't code in Java.. but my guess is you're making a silly mistake in > > there somewhere.. > > > Copy pasting some other person's posted code from the Java AppEngine group I > > see it done this way: > > > URL url = new URL(urlStr); > > URLFetchService urlFetchService = > > URLFetchServiceFactory.getURLFetchService(); > > HTTPRequest httpRequest = new > > HTTPRequest(url, HTTPMethod.GET,followRedirects()); > > HTTPResponse response = urlFetchService.fetch(httpRequest); > > > On Fri, Feb 19, 2010 at 4:27 PM, davidnelson < > > > david.jonathan.nel...@gmail.com> wrote: > > > weird, I get the same error even when I pin objects and call urlfetch > > > synchronously: > > > > url = new URL(urlString); > > > request = new HTTPRequest(url); > > > request.addHeader(userAgentHeader); > > > request.addHeader(authorizationHeader); > > > request.addHeader(acceptEncodingHeader); > > > request.addHeader(acceptCharsetHeader); > > > // undo pinning after debug > > > HTTPResponse response = > > > urlFetchService.fetch(request); > > > byte[] responseBytes = > > > response.getContent(); > > > String responseString = new > > > String(responseBytes); > > > parseResponse(responseString); > > > apiCallsMade++; > > > > On Feb 19, 7:33 am, Conor Power wrote: > > > > apologies if I'm a little vague in my reply but I remember receiving > > > > something similar when I first started using the URLFetchService and I > > > think > > > > it was related to the fact that I had imported the incorrect classes for > > > > HTTPRequest or header or something like like. I think I just chose the > > > first > > > > one offered to me by the IDE ... > > > > > It was a while ago so I hope I'm not sending you on a wild goose chase. > > > > > On Fri, Feb 19, 2010 at 4:52 AM, davidnelson < > > > > > david.jonathan.nel...@gmail.com> wrote: > > > > > Hi, > > > > > > I'm trying to implement async http in java. Here is the important > > > > > part of the code: > > > > > > for (String urlString : urls) > > > > > { > > > > > // TODO: try and get rid of these two > > > heap > > > > > allocations > > > > > url = new URL(urlString); > > > > > request = new HTTPRequest(url); > > > > > request.addHeader(userAgentHeader); > > > > > request.addHeader(authorizationHeader); > > > > > > > > > > request.addHeader(acceptEncodingHeader); > > > > > request.addHeader(acceptCharsetHeader); > > > > responses.add(URLFetchServiceFactory.getURLFetchService().fetchAsync(reques > > > t)); > > > > > apiCallsMade++; > > > > > } > > > > > for (Future futureResponse : > > > > > responses) > > > > > { > > > > > parseResponse(new > > > > > String(futureResponse.get().getContent())); > > > > > } > > > > > > I keep getting this error: "com.google.apphosting.api.ApiProxy > > > > > $CallNotFoundException: The API package 'ur
[google-appengine] Re: implementing asynchronous http in java
more info, I tried using the app engine version 1.3.0 and that's when I get nullpointerexceptions. switching back to 1.3.1 and I get the first exception I initially posted, sync or async. On Feb 19, 1:37 pm, Eli Jones wrote: > I don't code in Java.. but my guess is you're making a silly mistake in > there somewhere.. > > Copy pasting some other person's posted code from the Java AppEngine group I > see it done this way: > > URL url = new URL(urlStr); > URLFetchService urlFetchService = > URLFetchServiceFactory.getURLFetchService(); > HTTPRequest httpRequest = new > HTTPRequest(url, HTTPMethod.GET,followRedirects()); > HTTPResponse response = urlFetchService.fetch(httpRequest); > > On Fri, Feb 19, 2010 at 4:27 PM, davidnelson < > > > > david.jonathan.nel...@gmail.com> wrote: > > weird, I get the same error even when I pin objects and call urlfetch > > synchronously: > > > url = new URL(urlString); > > request = new HTTPRequest(url); > > request.addHeader(userAgentHeader); > > request.addHeader(authorizationHeader); > > request.addHeader(acceptEncodingHeader); > > request.addHeader(acceptCharsetHeader); > > // undo pinning after debug > > HTTPResponse response = > > urlFetchService.fetch(request); > > byte[] responseBytes = > > response.getContent(); > > String responseString = new > > String(responseBytes); > > parseResponse(responseString); > > apiCallsMade++; > > > On Feb 19, 7:33 am, Conor Power wrote: > > > apologies if I'm a little vague in my reply but I remember receiving > > > something similar when I first started using the URLFetchService and I > > think > > > it was related to the fact that I had imported the incorrect classes for > > > HTTPRequest or header or something like like. I think I just chose the > > first > > > one offered to me by the IDE ... > > > > It was a while ago so I hope I'm not sending you on a wild goose chase. > > > > On Fri, Feb 19, 2010 at 4:52 AM, davidnelson < > > > > david.jonathan.nel...@gmail.com> wrote: > > > > Hi, > > > > > I'm trying to implement async http in java. Here is the important > > > > part of the code: > > > > > for (String urlString : urls) > > > > { > > > > // TODO: try and get rid of these two > > heap > > > > allocations > > > > url = new URL(urlString); > > > > request = new HTTPRequest(url); > > > > request.addHeader(userAgentHeader); > > > > request.addHeader(authorizationHeader); > > > > request.addHeader(acceptEncodingHeader); > > > > request.addHeader(acceptCharsetHeader); > > > responses.add(URLFetchServiceFactory.getURLFetchService().fetchAsync(reques > > t)); > > > > apiCallsMade++; > > > > } > > > > for (Future futureResponse : > > > > responses) > > > > { > > > > parseResponse(new > > > > String(futureResponse.get().getContent())); > > > > } > > > > > I keep getting this error: "com.google.apphosting.api.ApiProxy > > > > $CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' > > > > was not found.". I looked around for any jars that were missing from > > > > the classpath but didn't see anything missing. Do you know which jar > > > > that code is in? I googled the error and also searched through this > > > > group but found nothing. > > > > > Thanks, > > > > David > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Google App Engine" group. > > > > To post to this group, send email to google-appengine@go
[google-appengine] Re: implementing asynchronous http in java
At this point I'm feeling not so smart :-( I can't even get synchronous urlfetch to work via the low level api: URL url = new URL("http://www.google.com";); URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService(); FetchOptions options = FetchOptions.Builder.followRedirects(); HTTPRequest httpRequest = new HTTPRequest(url, HTTPMethod.GET,options); HTTPResponse response = urlFetchService.fetch(httpRequest); it throws a nullpointerexception with no stack trace and no source code available to debug it. On Feb 19, 1:37 pm, Eli Jones wrote: > I don't code in Java.. but my guess is you're making a silly mistake in > there somewhere.. > > Copy pasting some other person's posted code from the Java AppEngine group I > see it done this way: > > URL url = new URL(urlStr); > URLFetchService urlFetchService = > URLFetchServiceFactory.getURLFetchService(); > HTTPRequest httpRequest = new > HTTPRequest(url, HTTPMethod.GET,followRedirects()); > HTTPResponse response = urlFetchService.fetch(httpRequest); > > On Fri, Feb 19, 2010 at 4:27 PM, davidnelson < > > > > david.jonathan.nel...@gmail.com> wrote: > > weird, I get the same error even when I pin objects and call urlfetch > > synchronously: > > > url = new URL(urlString); > > request = new HTTPRequest(url); > > request.addHeader(userAgentHeader); > > request.addHeader(authorizationHeader); > > request.addHeader(acceptEncodingHeader); > > request.addHeader(acceptCharsetHeader); > > // undo pinning after debug > > HTTPResponse response = > > urlFetchService.fetch(request); > > byte[] responseBytes = > > response.getContent(); > > String responseString = new > > String(responseBytes); > > parseResponse(responseString); > > apiCallsMade++; > > > On Feb 19, 7:33 am, Conor Power wrote: > > > apologies if I'm a little vague in my reply but I remember receiving > > > something similar when I first started using the URLFetchService and I > > think > > > it was related to the fact that I had imported the incorrect classes for > > > HTTPRequest or header or something like like. I think I just chose the > > first > > > one offered to me by the IDE ... > > > > It was a while ago so I hope I'm not sending you on a wild goose chase. > > > > On Fri, Feb 19, 2010 at 4:52 AM, davidnelson < > > > > david.jonathan.nel...@gmail.com> wrote: > > > > Hi, > > > > > I'm trying to implement async http in java. Here is the important > > > > part of the code: > > > > > for (String urlString : urls) > > > > { > > > > // TODO: try and get rid of these two > > heap > > > > allocations > > > > url = new URL(urlString); > > > > request = new HTTPRequest(url); > > > > request.addHeader(userAgentHeader); > > > > request.addHeader(authorizationHeader); > > > > request.addHeader(acceptEncodingHeader); > > > > request.addHeader(acceptCharsetHeader); > > > responses.add(URLFetchServiceFactory.getURLFetchService().fetchAsync(reques > > t)); > > > > apiCallsMade++; > > > > } > > > > for (Future futureResponse : > > > > responses) > > > > { > > > > parseResponse(new > > > > String(futureResponse.get().getContent())); > > > > } > > > > > I keep getting this error: "com.google.apphosting.api.ApiProxy > > > > $CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' > > > > was not found.". I looked around for any jars
[google-appengine] Re: implementing asynchronous http in java
weird, I get the same error even when I pin objects and call urlfetch synchronously: url = new URL(urlString); request = new HTTPRequest(url); request.addHeader(userAgentHeader); request.addHeader(authorizationHeader); request.addHeader(acceptEncodingHeader); request.addHeader(acceptCharsetHeader); // undo pinning after debug HTTPResponse response = urlFetchService.fetch(request); byte[] responseBytes = response.getContent(); String responseString = new String(responseBytes); parseResponse(responseString); apiCallsMade++; On Feb 19, 7:33 am, Conor Power wrote: > apologies if I'm a little vague in my reply but I remember receiving > something similar when I first started using the URLFetchService and I think > it was related to the fact that I had imported the incorrect classes for > HTTPRequest or header or something like like. I think I just chose the first > one offered to me by the IDE ... > > It was a while ago so I hope I'm not sending you on a wild goose chase. > > On Fri, Feb 19, 2010 at 4:52 AM, davidnelson < > > > > david.jonathan.nel...@gmail.com> wrote: > > Hi, > > > I'm trying to implement async http in java. Here is the important > > part of the code: > > > for (String urlString : urls) > > { > > // TODO: try and get rid of these two heap > > allocations > > url = new URL(urlString); > > request = new HTTPRequest(url); > > request.addHeader(userAgentHeader); > > request.addHeader(authorizationHeader); > > request.addHeader(acceptEncodingHeader); > > request.addHeader(acceptCharsetHeader); > > > responses.add(URLFetchServiceFactory.getURLFetchService().fetchAsync(reques > > t)); > > apiCallsMade++; > > } > > for (Future futureResponse : > > responses) > > { > > parseResponse(new > > String(futureResponse.get().getContent())); > > } > > > I keep getting this error: "com.google.apphosting.api.ApiProxy > > $CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' > > was not found.". I looked around for any jars that were missing from > > the classpath but didn't see anything missing. Do you know which jar > > that code is in? I googled the error and also searched through this > > group but found nothing. > > > Thanks, > > David > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google App Engine" group. > > To post to this group, send email to google-appeng...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-appengine+unsubscr...@googlegroups.com > e...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-appengine?hl=en. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] Re: implementing asynchronous http in java
guess I'll post on stackoverflow... On Feb 19, 7:33 am, Conor Power wrote: > apologies if I'm a little vague in my reply but I remember receiving > something similar when I first started using the URLFetchService and I think > it was related to the fact that I had imported the incorrect classes for > HTTPRequest or header or something like like. I think I just chose the first > one offered to me by the IDE ... > > It was a while ago so I hope I'm not sending you on a wild goose chase. > > On Fri, Feb 19, 2010 at 4:52 AM, davidnelson < > > > > david.jonathan.nel...@gmail.com> wrote: > > Hi, > > > I'm trying to implement async http in java. Here is the important > > part of the code: > > > for (String urlString : urls) > > { > > // TODO: try and get rid of these two heap > > allocations > > url = new URL(urlString); > > request = new HTTPRequest(url); > > request.addHeader(userAgentHeader); > > request.addHeader(authorizationHeader); > > request.addHeader(acceptEncodingHeader); > > request.addHeader(acceptCharsetHeader); > > > responses.add(URLFetchServiceFactory.getURLFetchService().fetchAsync(reques > > t)); > > apiCallsMade++; > > } > > for (Future futureResponse : > > responses) > > { > > parseResponse(new > > String(futureResponse.get().getContent())); > > } > > > I keep getting this error: "com.google.apphosting.api.ApiProxy > > $CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' > > was not found.". I looked around for any jars that were missing from > > the classpath but didn't see anything missing. Do you know which jar > > that code is in? I googled the error and also searched through this > > group but found nothing. > > > Thanks, > > David > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google App Engine" group. > > To post to this group, send email to google-appeng...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-appengine+unsubscr...@googlegroups.com > e...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-appengine?hl=en. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] Re: implementing asynchronous http in java
Thanks Conor, I tried a "brute force" approach of just importing the whole namespace: import com.google.appengine.api.urlfetch.*; Still get the error :-( Thanks, David On Feb 19, 7:33 am, Conor Power wrote: > apologies if I'm a little vague in my reply but I remember receiving > something similar when I first started using the URLFetchService and I think > it was related to the fact that I had imported the incorrect classes for > HTTPRequest or header or something like like. I think I just chose the first > one offered to me by the IDE ... > > It was a while ago so I hope I'm not sending you on a wild goose chase. > > On Fri, Feb 19, 2010 at 4:52 AM, davidnelson < > > > > david.jonathan.nel...@gmail.com> wrote: > > Hi, > > > I'm trying to implement async http in java. Here is the important > > part of the code: > > > for (String urlString : urls) > > { > > // TODO: try and get rid of these two heap > > allocations > > url = new URL(urlString); > > request = new HTTPRequest(url); > > request.addHeader(userAgentHeader); > > request.addHeader(authorizationHeader); > > request.addHeader(acceptEncodingHeader); > > request.addHeader(acceptCharsetHeader); > > > responses.add(URLFetchServiceFactory.getURLFetchService().fetchAsync(reques > > t)); > > apiCallsMade++; > > } > > for (Future futureResponse : > > responses) > > { > > parseResponse(new > > String(futureResponse.get().getContent())); > > } > > > I keep getting this error: "com.google.apphosting.api.ApiProxy > > $CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' > > was not found.". I looked around for any jars that were missing from > > the classpath but didn't see anything missing. Do you know which jar > > that code is in? I googled the error and also searched through this > > group but found nothing. > > > Thanks, > > David > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google App Engine" group. > > To post to this group, send email to google-appeng...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-appengine+unsubscr...@googlegroups.com > e...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-appengine?hl=en. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] implementing asynchronous http in java
Hi, I'm trying to implement async http in java. Here is the important part of the code: for (String urlString : urls) { // TODO: try and get rid of these two heap allocations url = new URL(urlString); request = new HTTPRequest(url); request.addHeader(userAgentHeader); request.addHeader(authorizationHeader); request.addHeader(acceptEncodingHeader); request.addHeader(acceptCharsetHeader); responses.add(URLFetchServiceFactory.getURLFetchService().fetchAsync(request)); apiCallsMade++; } for (Future futureResponse : responses) { parseResponse(new String(futureResponse.get().getContent())); } I keep getting this error: "com.google.apphosting.api.ApiProxy $CallNotFoundException: The API package 'urlfetch' or call 'Fetch()' was not found.". I looked around for any jars that were missing from the classpath but didn't see anything missing. Do you know which jar that code is in? I googled the error and also searched through this group but found nothing. Thanks, David -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.