-2

I am trying to write an applet that run in html page . If I run the applet in eclipse with debug as JApplet it runs fine, but if i put it in an html it has an error.

Java console say :

basic: eccezione: java.lang.ExceptionInInitializerError java.lang.RuntimeException: java.lang.ExceptionInInitializerError at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ExceptionInInitializerError at org.restlet.resource.ClientResource.(ClientResource.java:405) at com.gabrielepiscitelli.JAppletGui.RestClient.Client.listAllThreads(Client.java:39) at com.gabrielepiscitelli.JAppletGui.Gui.GUIApplet.(GUIApplet.java:191) 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.newInstance(Unknown Source) at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$400(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(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) Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.util.logging.config.file" "read") at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPropertyAccess(Unknown Source) at java.lang.System.getProperty(Unknown Source) at org.restlet.engine.Engine.configureLog(Engine.java:194) at org.restlet.engine.Engine.register(Engine.java:380) at org.restlet.engine.Engine.register(Engine.java:368) at org.restlet.engine.Engine.getInstance(Engine.java:252) at org.restlet.data.Method.(Method.java:334) at org.restlet.data.Method.(Method.java:393) at org.restlet.data.Method.(Method.java:358) at org.restlet.data.Method.(Method.java:57) ... 28 more

the code at Client.java:39 is the line cr = new ClientResource(lURI); in this part of java file:

 /**
 * 
 */
package com.gabrielepiscitelli.JAppletGui.RestClient;

import java.io.IOException;

import org.restlet.data.Status;
import org.restlet.resource.ClientResource;
import org.restlet.resource.ResourceException;

import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiPost;
import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiThread;
import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiUser;
import com.gabrielepiscitelli.SystemForum.Utils.ExceptionForum;
import com.google.gson.Gson;

/**
 * @author Gabriele
 *
 */
public class Client {
    /**
     * 
     * @return
     * @throws ExceptionForum 
     */
    public static DataGuiThread[] listAllThreads() throws ExceptionForum{

        DataGuiThread[] lRestDataGuiThreads = null;

        ClientResource cr   = null;
        Gson gson           = new Gson();
        Status status       = null;
        String json         = null;

        String lURI = "http://localhost:8182/ListThreadsAll";

        cr = new ClientResource(lURI);
        try {
            json = cr.get().getText();
            status = cr.getStatus();

            if (status.getCode() != 200) {
//              System.out.println(status);
//              System.exit(status.getCode());
                Status lStatusJson = gson.fromJson(json, Status.class);
                throw new ExceptionForum(ExceptionForum.ExType.CLIENT, 
                          "Client error.", 
                          lStatusJson.getDescription() + lStatusJson.getReasonPhrase());
            } else {
                lRestDataGuiThreads = gson.fromJson(json, DataGuiThread[].class);
            }

        } catch (ResourceException e) {
//          e.printStackTrace();
            throw new ExceptionForum(ExceptionForum.ExType.CLIENT, 
                      "Client error.", 
                      e.getMessage());

        } catch (IOException e) {
//          e.printStackTrace();
            throw new ExceptionForum(ExceptionForum.ExType.CLIENT, 
                      "Client error.", 
                      e.getMessage());
        }

        return lRestDataGuiThreads;
    }

Html file is simply :

<html><body>
 <p>
  <applet code="com.gabrielepiscitelli.JAppletGui.Gui.GUIApplet.class" archive="GUIApplet.jar,miglayout15-swing.jar,org.restlet.jar,gson-2.2.4.jar"
   width="800" height="640"></applet>
 </p>

Is there someone that can explain me the problem? thanks in advances!

gpiscite
  • 23
  • 7

1 Answers1

1
Caused by: java.security.AccessControlException: access denied
    ("java.util.PropertyPermission" "java.util.logging.config.file" "read")

This applet needs to be trusted. Digitally sign the applet code.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433