Solved

java.security.AccessControlException: access denied

Posted on 2006-11-10
4
561 Views
Last Modified: 2008-01-09
Hi Experts,

I am trying to run Chat sample program and have this “java.security.AccessControlException: access denied “ error.

After searching for the cause, it looks like I need to modify one of the java security files, but I don’t have much clue. Can somebody help me on this?

Thanks,

+++++++++
java.security.AccessControlException: access denied (java.net.SocketPermission 1
27.0.0.1:1099 connect,resolve)
        at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:269)
        at java.security.AccessController.checkPermission(AccessController.java:
401)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
        at java.lang.SecurityManager.checkConnect(SecurityManager.java:1026)
        at java.net.Socket.connect(Socket.java:446)
        at java.net.Socket.connect(Socket.java:402)
        at java.net.Socket.<init>(Socket.java:309)
        at java.net.Socket.<init>(Socket.java:124)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:22)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:128)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185
)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
        at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
        at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
        at java.rmi.Naming.rebind(Naming.java:160)
        at RemoteModel.setOnline(RemoteModel.java:155)
        at RemoteModel.setModelName(RemoteModel.java:136)
        at ChatRoom.setSubject(ChatRoom.java:119)
        at ChatRoom.<init>(ChatRoom.java:54)
        at ChatRoom.main(ChatRoom.java:194)
0
Comment
Question by:dkim18
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 350 total points
ID: 17919791
Please see if the following suits your need:

http://archives.java.sun.com/cgi-bin/wa?A2=ind0006&L=rmi-users&P=29236
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17919917
you can't connect/resolve from the applet. if you want to do so, you need to sign the applet and distribute
0
 

Author Comment

by:dkim18
ID: 17922100
pkwan,

I added these line in java.policy file:

permission java.net.SocketPermission "localhost:1099","accept,connect,resolve,listen";
permission java.net.SocketPermission "*:1099","connect,accept,resolve";

but still having error:

C:\P3_1>java ChatRoom Nutrition Vicki
java.security.policy: error parsing file:/C:/Java/j2sdk1.4.2_09/jre/lib/security
/java.policy:
        line 1: expected [;], found [permission]
java.security.AccessControlException: access denied (java.net.SocketPermission 1
27.0.0.1:1099 connect,resolve)
        at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:269)
        at java.security.AccessController.checkPermission(AccessController.java:
401)
...
...
...
0
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 17923968
You should put the lines into grant block:

example:

grant {
permission java.net.SocketPermission "localhost:1099","accept,connect,resolve,listen";
permission java.net.SocketPermission "*:1099","connect,accept,resolve";

}
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question