我正在尝试编写一个在html页面中运行的applet。 如果我在eclipse中使用debug作为JApplet运行applet它运行正常,但如果我把它放在一个html中它有一个错误。
Java控制台说:
基本:eccezione:java.lang.ExceptionInInitializerError java.lang.RuntimeException:java.lang.ExceptionInInitializerError at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source) 在sun.plugin2.applet.Plugin2Manager.initAppletAdapter(未知来源) at sun.plugin2.applet.Plugin2Manager $ AppletExecutionRunnable.run(Unknown Source) 在java.lang.Thread.run(未知来源) 引起:java.lang.ExceptionInInitializerError 在org.restlet.resource.ClientResource。(ClientResource.java:405) 在com.gabrielepiscitelli.JAppletGui.RestClient.Client.listAllThreads(Client.java:39) 在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) 在java.lang.Class.newInstance(未知来源) 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) 在java.awt.EventQueue.access $ 400(未知来源) 在java.awt.EventQueue $ 3.run(未知来源) 在java.awt.EventQueue $ 3.run(未知来源) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(Unknown Source) 在java.awt.EventQueue $ 4.run(未知来源) 在java.awt.EventQueue $ 4.run(未知来源) 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) 引起:java.security.AccessControlException:拒绝访问(" java.util.PropertyPermission"" java.util.logging.config.file""读") at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) 在java.lang.SecurityManager.checkPermission(未知来源) at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPropertyAccess(Unknown Source) 在java.lang.System.getProperty(未知来源) 在org.restlet.engine.Engine.configureLog(Engine.java:194) 在org.restlet.engine.Engine.register(Engine.java:380) 在org.restlet.engine.Engine.register(Engine.java:368) 在org.restlet.engine.Engine.getInstance(Engine.java:252) 在org.restlet.data.Method。(Method.java:334) 在org.restlet.data.Method。(Method.java:393) 在org.restlet.data.Method。(Method.java:358) 在org.restlet.data.Method。(Method.java:57) ......还有28个
Client.java:39中的代码是java文件的这一部分中的行cr = new ClientResource(lURI);
:
/**
*
*/
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文件很简单:
<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>
有人可以解释我的问题吗?谢谢你的进步!
答案 0 :(得分:1)
Caused by: java.security.AccessControlException: access denied
("java.util.PropertyPermission" "java.util.logging.config.file" "read")
此applet需要信任。对applet代码进行数字签名。