Fetch URL problem nullpointerexception

180 views
Skip to first unread message

Mario Buonomo

unread,
Oct 12, 2012, 11:37:10 AM10/12/12
to google-a...@googlegroups.com
Hi, I've a problem with fetch URL using appengine.. 

the problem is on url.openStream() (nullpointerexception) but url is not null

this is my code:

 try {
            URL url
= new URL(site);
           
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
           
String line;
           
while ((line = reader.readLine()) != null) {             
           
}
            reader
.close();
       
} catch (MalformedURLException e) {       
       
} catch (Exception e) {
       
}
 the error is:
java.lang.NullPointerException
at java.util.Collections.addAll(Unknown Source)
at sun.security.ssl.AbstractTrustManagerWrapper.<init>(Unknown Source)
at sun.security.ssl.SSLContextImpl.chooseTrustManager(Unknown Source)
at sun.security.ssl.SSLContextImpl.engineInit(Unknown Source)
at javax.net.ssl.SSLContext.init(Unknown Source)
at com.google.appengine.api.urlfetch.dev.LocalURLFetchService.createNonvalidatingScheme(LocalURLFetchService.java:241)
at com.google.appengine.api.urlfetch.dev.LocalURLFetchService.createHttpClient(LocalURLFetchService.java:263)
at com.google.appengine.api.urlfetch.dev.LocalURLFetchService.getNonValidatingClient(LocalURLFetchService.java:508)
at com.google.appengine.api.urlfetch.dev.LocalURLFetchService.access$100(LocalURLFetchService.java:82)
at com.google.appengine.api.urlfetch.dev.LocalURLFetchService$7.run(LocalURLFetchService.java:422)
at com.google.appengine.api.urlfetch.dev.LocalURLFetchService$7.run(LocalURLFetchService.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.api.urlfetch.dev.LocalURLFetchService.doPrivilegedExecute(LocalURLFetchService.java:409)
at com.google.appengine.api.urlfetch.dev.LocalURLFetchService.fetch(LocalURLFetchService.java:377)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:527)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:481)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:458)
at java.util.concurrent.Executors$PrivilegedCallable$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.concurrent.Executors$PrivilegedCallable.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

the same in a simple java app work fine..

I had test in local 
can you help me?

Vinny P

unread,
Oct 12, 2012, 12:29:01 PM10/12/12
to google-a...@googlegroups.com
Are you using Java 7? If so, you need to downgrade to Java 6. This is a known bug (you can see a similar stacktrace from Oracle: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7145592 the only workaround listed is to use Java 6). 

If I recall correctly, App Engine only supports Java 5 & 6, not 7.

If you're not using Java 7, you'll have to post more of your code. Or deploy your app to App Engine production and see if the problem fixes itself; you may have an issue with your local dev environment.

-Vinny P

Mario Buonomo

unread,
Oct 13, 2012, 4:12:37 AM10/13/12
to google-a...@googlegroups.com
WOW thank you very much ;)

It's work, this is a very strange bug..

Mario
Reply all
Reply to author
Forward
0 new messages