当我尝试在 jsp 上运行小程序时出现 AccessControlException

发布于 2025-01-05 20:09:45 字数 1435 浏览 2 评论 0原文

当我运行 jsp 页面时,我遇到了异常,在该页面中我嵌入了小程序,

我的 jsp 文件代码

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
     <body>
      <applet code="myform.applet" archive="applet.jar,ojdbc14.jar" width="600" height="480"/>
    </body>
</html>

applet.jar 在其中创建了一个类,我在其中尝试从 oracle 数据库表中检索数据库值。

和例外,

Exception in thread "thread applet-myform.applet-1" java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at myform.applet.init(applet.java:28)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
    at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:316)
    ... 5 more

我到处搜索,但没有得到我的解决方案,并且在某个地方已经以广泛的方式解释了它,作为新手我无法理解。请帮助我,这两天我一直被这个问题困扰。提前致谢。

I'm getting exception when i'm running my jsp page, in which i've embedded the applet

my jsp file code

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
     <body>
      <applet code="myform.applet" archive="applet.jar,ojdbc14.jar" width="600" height="480"/>
    </body>
</html>

applet.jar in which i've made one class, in which i'm trying to retrieve the database values from the oracle database table.

and exception through

Exception in thread "thread applet-myform.applet-1" java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at myform.applet.init(applet.java:28)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
    at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:316)
    ... 5 more

I searched everywhere, but didn't get my solution and somewhere it has been explained in a broad manner, which i can't understand as a newbie. Please help me, i'm stuck with this problem since last two days. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里°也失望 2025-01-12 20:09:45

小程序在安全环境中运行。 SecurityManager 控制小程序正在执行的操作,并不允许它执行禁止的操作。

从堆栈跟踪中我们可以看到 Oracle 驱动程序尝试访问 Applet 禁止的系统类加载器。

通常有 3 种方法可以解决这个问题。

  1. 签署您的小程序。在这种情况下,你将能够做一切事情。但要小心。下一个问题是驱动程序将无法连接到数据库,因为客户端浏览器和运行 Oracle 的服务器之间存在防火墙。
  2. 将您的客户端开发为常规应用程序并使用 Java web start 来启动它。用户仍然可以通过单击网络浏览器中的链接来启动应用程序,但他将获得功能齐全的应用程序(与签名小程序的情况完全相同)。防火墙问题在这里仍然相关。
  3. 创建 3 层应用程序。前端可以是小程序或瘦客户端。业务逻辑可能是一个简单的 Web 应用程序,它公开 RESTful API 并连接到数据库以检索和存储数据。

Applets run in secured environment. The SecurityManager controls what applet is doing and does not allow it to perform forbidden operations.

From stack trace we can see that Oracle driver tries to access system class loader that is forbidden for applet.

You have generally 3 ways to solve this problem.

  1. Sign your applet. In this case you will be able to do everything. But be careful. The next problem will be that the driver will not be able to connect to DB because of firewall between your client's browser and server where Oracle is running.
  2. Develop your client as regular application and use Java web start to start it. User can still start the application by clicking link in his web browser but he will get fully functional application (exactly as in case of signed applet). The firewall problem is still relevant here.
  3. Create 3 tier application. The frontend may be either applet or thin client. The business logic may be a simple web application that expose RESTful API and connects to DB to retrieve and store data.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文