Results 1 to 12 of 12

Thread: RMI applet

  1. #1
    Dennis's Avatar
    Dennis is offline Member
    Join Date
    May 2010
    Posts
    83
    Rep Power
    0

    Default RMI applet

    I've created an simple RMI program,
    When I put it into a jframe and compile to a .jar file it works good.
    And when I run it as applet in the appletViewer it works good.

    But when I run it as applet in IE I got this error:
    Java Code:
    java.lang.reflect.InvocationTargetException
    	at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission java.security.policy write)
    	at java.security.AccessControlContext.checkPermission(Unknown Source)
    	at java.security.AccessController.checkPermission(Unknown Source)
    	at java.lang.SecurityManager.checkPermission(Unknown Source)
    	at java.lang.System.setProperty(Unknown Source)
    	at loader.<init>(loader.java:27)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    	at java.lang.reflect.Constructor.newInstance(Unknown Source)
    	at java.lang.Class.newInstance0(Unknown Source)
    	at java.lang.Class.newInstance(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    Exception: java.lang.reflect.InvocationTargetException
    Does someone know how I can fix this?

    Thanks,
    Dennis

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    access denied (java.util.PropertyPermission java.security.policy write)
    Looks like the applet is trying to change a property. Applets are NOT allowed to change anything on a client without permission.
    You can give permission to the applet by signing its jar or by adding an entry to the client's .java.policy file.

  3. #3
    Dennis's Avatar
    Dennis is offline Member
    Join Date
    May 2010
    Posts
    83
    Rep Power
    0

    Default

    In the inside the client.java is this line
    Java Code:
    System.setProperty("java.security.policy", "security.policy");
    and inside the "security.policy":
    Java Code:
    grant {
      permission java.security.AllPermission;
    };

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Have you tried it in other browsers?

    Also have you tried adding that permission statement to the .java.policy file?

    How does the JVM connect to the security.policy file you show?
    Last edited by Norm; 07-13-2010 at 03:32 PM.

  5. #5
    Dennis's Avatar
    Dennis is offline Member
    Join Date
    May 2010
    Posts
    83
    Rep Power
    0

    Default

    There is no connection with the JVM and the security.policy only between the applet and the "security.policy".

    Why the java.policy file? I use the security.policy file.

    In Mozilla Firefox it don't work too.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    The applet needs a JVM to execute.
    How does the applet's JVM connect to the security.policy file you've created?
    The applet's JVM does use a .java.policy when it executes. There is a chain of pointers from the JVM's lib\security folder to the .java.policy file.

    Why do you think the applet's JVM will look at your security.policy file?

  7. #7
    Dennis's Avatar
    Dennis is offline Member
    Join Date
    May 2010
    Posts
    83
    Rep Power
    0

    Default

    I think the applet('s JVM) connect to the security.policy file with the line "System.setProperty("java.security.policy", "security.policy");"

    But how do you think how I can add an java.security.policy file to my applet?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Its a catch-22 situation. The setProperty() is NOT allowed without the permission.

    I don't know how to add your policy file for a JVM used to execute an applet in a browser.

    That's why I was talking about using the .java.policy file that IS used by the JVM via links in a lib\security folder file.

    Try adding the permission in your policy file to the .java.policy file and see what happens.

  9. #9
    Dennis's Avatar
    Dennis is offline Member
    Join Date
    May 2010
    Posts
    83
    Rep Power
    0

    Default

    You mean I must set into the client "System.setProperty("file://C:/Program Files/Java/jre6/lib/security/java.policy")"?

    (now I'm not on my own computer and can't try it)

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    No the java.policy is NOT the file I was talking about. I referred to the .java.policy file which is somewhere in the user's folders NOT in the JRE's folders.
    You use the policytool to make changes to the .java.policy file.

    Where are you executing this command?
    System.setProperty("file://C:/Program Files/Java/jre6/lib/security/java.policy")

    An Applet can NOT do a setProperty() without permission.

  11. #11
    swetamakode is offline Member
    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Default Re: RMI applet

    Hi,

    I am also facing the same issue when using setProperty() in applet.I have created the signed applet using jarsigner and in my .jar file I kept the java.policy file to grant all permission but still I am getting the same exception.

    Please let me know how to fix it?

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: RMI applet

    Don't post to old dead threads and don't hijack another poster's thread. When you have a question, start your own thread -- they're free.

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 2
    Last Post: 09-29-2009, 03:33 PM
  2. Calling another applet on click of button in one applet
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 1
    Last Post: 02-19-2009, 12:54 PM
  3. Applet in a GUI
    By serfster in forum New To Java
    Replies: 1
    Last Post: 06-12-2008, 11:09 PM
  4. First Applet HELP????
    By nvidia in forum New To Java
    Replies: 0
    Last Post: 08-13-2007, 10:11 PM
  5. Replies: 4
    Last Post: 06-08-2007, 06:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •