我创建了一个名为test.jar的.jar文件,并尝试将其放入名为login.html的网页(全部在本地)。在applet标签中,我将mysqlconnector.jar和test.jar放在归档部分。
当我尝试使用appletviewer“file:/// c:/test/login.html”运行applet时,applet加载但是当我尝试登录并单击ok时出现以下错误
Exception in thread "AWT-EventQueue-1" java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:286)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at staffDatabase.queryStaffID(staffDatabase.java:76)
at searchStaff.readFromLogin(searchStaff.java:14)
at loginFrame$1.actionPerformed(loginFrame.java:65)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
95)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.security.AccessControlException: access denied (java.util.Proper
tyPermission file.encoding read)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:323)
at java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:12
85)
at java.lang.System.getProperty(System.java:650)
at com.mysql.jdbc.StringUtils.<clinit>(StringUtils.java:70)
... 30 more
我查看了其他一些建议
的网站 Caused by: java.security.AccessControlException: access denied (java.util.Proper
tyPermission file.encoding read)
是由于缺少来自policytool的读取权限,但我已经启用了所有权限,这没有任何区别。
任何帮助将不胜感激!到目前为止,我到处都看不到运气,谢谢!
答案 0 :(得分:2)
更改策略文件不会削减它,您仍然需要sign the applet。请注意,您可以选择通过JNLP部署应用。这将为您提供更高的默认权限集,但是对于您正在执行的操作(请求套接字权限),仍然需要对应用程序进行签名。