wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes java.security.  AccessControlException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.security.  AccessControlException" Watch "java.security.  AccessControlException" New topic

java.security. AccessControlException

Joel Cohen

Joined: Dec 24, 2002
Posts: 6
I'm running Tomcat 4. I've written an applet which talks to a servlet:
URL myConnection = new URL("http://joelhost:8080/portfolio/servlet/ +
URLConnection myConn = myConnection.openConnection();
It works fine when I run it the same machine (A). But when I try to run the applet from machine (B), I get the following messages:
java.security.AccessControlException: access denied (java.net.SocketPermission joelhost:8080 connect,resolve)
at java.security.AccessControlContext.
checkPermission (AccessControlContext.java:270)
at java.security. AccessController.
checkPermission (AccessController.java:401)
at java.lang. SecurityManager.
checkPermission (SecurityManager.java:542)
at java.lang. SecurityManager.
checkConnect (SecurityManager.java:1044)
at sun.plugin. net.protocol.http.
HttpURLConnection. checkPermission
(HttpURLConnection. java:203)
at sun.plugin.net. protocol.http.
at sun.plugin. net.protocol.
http.HttpURLConnection. getInputStream
(HttpURLConnection. java:375)
at portfolio. acctSetup.<init>
at myApp.jbInit (myApp.java:76)
at myApp.init (myApp.java:40)
at sun.applet. AppletPanel.run (AppletPanel.java:347)
at java.lang.Thread.run (Thread.java:536)
I've made the following entry in catalina.policy
grant codeBase "file:${catalina.home}/webapps/portfolio +
/WEB-INF/classes/-" {
permission java.net.SocketPermission "joelhost", "connect";
Any ideas out there?
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Joel,

I've made the following entry in catalina.policy

but are not these changes applied to only the local machine where the tomcat is running? in that case it will replace only local java.policy file where the tomcat is residing but if you want to access the applet from another machine then the java.policy file on THAT machine (from where you are running the applet) should be changed to grant the permissions, right??
please let me know if i misunderstood your question or sound dumb on the X'Mas morning
Joel Cohen

Joined: Dec 24, 2002
Posts: 6
I don't think I should have to change the Java policy file on machine B.
Anyway, I've put the problem aside for now. I'm developing the program using JSP's and servlets instead of applets. Keeps it thinner.
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi joel,

i thought so because its the local machine who is trying to run the applet. so it must be the local machine adminstrator who should be able to specify the access rights etc you know. catalina.policy is a server side configuration , right?
so server A can't say that on Machine B some applet can do "delete *.*" you know
please let me know when you found a solution to your problem. i'm more interested because i have never used (or didn't know about catalina.policy file till this moment) catalina.policy file....
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Joel,
any progress on the issue?
Ali Sha

Joined: Mar 15, 2004
Posts: 2
Dear Maulin:
I saw your respond to Joel and I decided to ask you to help us;
if an applet,which is deployed on Server1 and a client of Server1 access that applet, on a certain condition this applet invokes a servlet from Server2(remember applet is deployed on server1) then a scoket exception occures... following is the code of applet which is deployed on Server1
try {
URL dataURL = null;
URLConnection connection = null;
dataURL = new URL("http://Server2:8080/cFAS/servlet/ServletOpnControl");
System.out.println("...." + dataURL.toString());
connection = dataURL.openConnection();
ObjectInputStream in = new ObjectInputStream(connection.getInputStream());
String[] data1 = (String[]) in.readObject();
} catch (Exception mue) {
here is the exception:
java.security.AccessControlException: access denied (java.net.SocketPermission Server2:8080 connect,resolve)
Thanks in advance
I agree. Here's the link: http://aspose.com/file-tools
subject: java.security. AccessControlException
Similar Threads
applet servlet communication
Problem RMI and Applet (java.security. AccessControlException)
Applet-servlet communication
problems naming a host parameter
Problem with Sun's Bootstraping Example