Results 1 to 3 of 3

Thread: Applet has java.lang.Runtime.addShutdownHook exception - want to avoid ICE setup

  1. #1
    Jon S is offline Registered User
    Name: Jon Strabala
    Organization: Quantum Systems Integrators, Inc.
    Project: eval
    Join Date
    May 2011
    Posts
    7

    Applet has java.lang.Runtime.addShutdownHook exception - want to avoid ICE setup

    Hello,

    Applet failure I call my method Z.createConnection and I will get an exception with "java.lang.Runtime.addShutdownHook". This is all realted to java.security.AccessControlException: access denied (java.lang.RuntimePermission shutdownHooks) which is triggered by an Ice call.

    Is there any way to disable the shutdown hook setup? ( note - signing the JAR or using JNLP is not an option for me ).

    Do I have to hack the code or is there some method to call to prevent the Ice.Application.changeHook(...) call.

    Code:
    public class Z extends Ice.Application
    {
        public void createConnection()
        {
            String[] custArgs = new String[7];
            custArgs[0] = "--Ice.MessageSizeMax=16384"; // 16 mega-bytes
            custArgs[1] = "--Ice.BatchAutoFlush=1";
            custArgs[2] = "--Ice.ACM.Client=0";
            custArgs[3] = "--Ice.ThreadPool.Client.Size=1";
            custArgs[4] = "--Ice.ThreadPool.Client.SizeMax=15";
            custArgs[5] = "--Ice.ThreadPool.Server.Size=1";
            custArgs[6] = "--Ice.ThreadPool.Server.SizeMax=15";
    
            int status = main("CROME", custArgs);
        }
    }
    I get the following message:

    Code:
    network: Connecting http://binky.quantumsi.com/jbin/Zcheck?cmd=header with cookie "__utma=121695755.852096886.1270944348.1270944348.1270944348.1"
    !! 6/6/11 16:29:04:074 CROME: error: Thread-18: unknown exception: java.security.AccessControlException: access denied (java.lang.RuntimePermission shutdownHooks)
           at java.security.AccessControlContext.checkPermission(Unknown Source)
           at java.security.AccessController.checkPermission(Unknown Source)
           at java.lang.SecurityManager.checkPermission(Unknown Source)
           at java.lang.Runtime.addShutdownHook(Unknown Source)
           at Ice.Application.changeHook(Application.java:498)
           at Ice.Application.destroyOnInterrupt(Application.java:348)
           at Ice.Application.doMain(Application.java:197)
           at Ice.Application.main(Application.java:180)
           at Ice.Application.main(Application.java:71)
           at Z.createConnection(BRXE)
           at Z.init(BRXE)
           at Zmain.run(BRXE)
    Thanks in Advance

    Jon

  2. #2
    xdm's Avatar
    xdm
    xdm is offline ZeroC Staff
    Name: Jose Gutierrez de la Concha
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Sep 2003
    Location
    La Coruņa, Spain
    Posts
    588
    You can call the overload of Application that receive a SignalPolicy with SignalPolicy.NoSignalHandling this will avoid the setup of the shutdown hook. But Ice.Application isn't interesting for Applets as isn't designed to work with the applet life cycle "start/init/stop/destroy".

    For a complete applet demo see java/demo/Ice/applet in Ice distribution. This demo shows how to integrate the Ice run time, with the applet life cycle.

  3. #3
    Jon S is offline Registered User
    Name: Jon Strabala
    Organization: Quantum Systems Integrators, Inc.
    Project: eval
    Join Date
    May 2011
    Posts
    7
    Thanks xdm,

    The below seems to have worked for me, e.g. using Ice.Application with a basic Applet

    Code:
    import Ice.SignalPolicy;
    
    public class Z extends Ice.Application
    {
        public Z() {
            // Do this only if using an unsigned applet, JNLP and signed applets
            // can and should handle a shutdown hook. Since this mode is
            // "read-only' I am not concerned about 'bad' items like file
            // and/or database corruption.
            super(SignalPolicy.NoSignalHandling);
        }
    
        // other code/methods removed here ....
    }
    The overload of Application that receive a SignalPolicy with SignalPolicy.NoSignalHandling did avoid the shutdown hook issue.

    I understand your comment But Ice.Application isn't interesting for Applets as isn't designed to work with the applet life cycle "start/init/stop/destroy". but this solved an immediate issue with minimal code changes.

    As per your direction I will inspect the applet demo see java/demo/Ice/applet in Ice distribution which you state shows how to integrate the Ice run time, with the applet life cycle. IMHO I think this will be much more inline with my intended use case.

    Thanks for the prompt pointer to the solution

    Jon S.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 11-18-2008, 09:06 PM
  2. Is it possible using ICE with Java applet?
    By Yunqiao Yin in forum Help Center
    Replies: 6
    Last Post: 01-07-2008, 08:41 PM
  3. Replies: 2
    Last Post: 11-24-2006, 03:03 AM
  4. java.lang.StackOverflowError
    By brian in forum Help Center
    Replies: 1
    Last Post: 03-12-2004, 07:21 AM
  5. java.lang.StackOverflowErrors
    By brian in forum Help Center
    Replies: 1
    Last Post: 10-28-2003, 04:42 PM

Posting Permissions

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