1

I am trying to execute this program, http://java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/WebCrawler.java The program compiles without any error after i referred this page, http://www.velocityreviews.com/forums/t146972-web-crawler.html

But while executing using the command "appletviewer WebCrawler.html" i get this exception..

Exception in thread "Thread-4" 
java.security.AccessControlException:access denied(java.net.SocketPermission java.sun.com:80 connect,resolve)

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)

at java.security.AccessController.checkPermission(AccessController.java:546)

at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)

at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)

at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)

at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)

at sun.net.www.http.HttpClient.New(HttpClient.java:306)

at sun.net.www.http.HttpClient.New(HttpClient.java:323)

at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860)

at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801)

at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)

at java.net.URL.openStream(URL.java:1010)

at WebCrawler.robotSafe(WebCrawler.java:139)

at WebCrawler.run(WebCrawler.java:235)

at java.lang.Thread.run(Thread.java:619)

How do i make it work.?

Roman C
  • 49,761
  • 33
  • 66
  • 176
rakesh
  • 23
  • 5

2 Answers2

1

By default, an applet may only connect to the same server + port from which it is located. You could do one of the following:

  1. Convert the app into an application, removng the security restriction
  2. Use a trusted/signed applet

Also you could have a look at configuring the crossdomain for the applet, see:

http://weblogs.java.net/blog/2008/05/28/java-doodle-crossdomainxml-support

Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • Reimus- I tried to convert it into a signed applet. But i am struck in assigning the start class in MANIFEST File. Which class should i add? This "public class WebCrawler extends Applet implements ActionListener, Runnable" class must be added or "public static void main (String argv[])" must be added.? – rakesh Jul 14 '12 at 06:14
0

It's pretty straight forward to self-sign an applet (which you can do for free). If you don't sign the applet you'll only get bare minimum security access and won't give access to the sockets.

Simple 3 step guide is here:

http://www.narendranaidu.com/2007/11/3-easy-steps-to-self-sign-applet-jar.html

or a more in-depth explination: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html