I'm using Quercus/PHP on AppEngine. When I run a simple script with file_get_contents($url); I get an error:
java.lang.NoClassDefFoundError: java.net.Socket is a restricted class. Please see the Google App Engine developer's guide for more details.
I've googled and although I find that other's have run into the same error, but the cause seems the vary. What do you think is cousing this error for me?
I'm using the latest AppEngine Java SDK, and the latest Quercus.
olivierlemasle is right, but here is the solution that I found after some more searching; in the comments section, user "Phil" recommend:
import java.net.URL;
define('URLFetchServiceFactory', new Java('com.google.appengine.api.urlfetch.URLFetchServiceFactory'));
$data = URLFetchServiceFactory->getURLFetchService()->fetch(new URL($url))->getContent();
Tested, and it worked!
When using Google AppEngine/Java, you don't really have access to a complete JVM: your applications run in a restricted sandbox. See documentation here :
https://developers.google.com/appengine/docs/java/runtime?hl=en#The_Sandbox
According to this documentation, you cannot open a socket in this sandbox. That's why it's written that "java.net.Socket is a restricted class".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With