我一直在研究Java项目。它现在已经结束,但Java Web start无法运行。我编译程序并将dist文件放在我的Tomcat服务器中。我希望客户下载我的程序并用作桌面应用程序。
我可以在Netbeans IDE中运行该程序,但是当我使用.jnlp
文件尝试它时,它会给出错误。直到不久前,我设法使用jnlp运行该程序,不知怎的,它给出了以下错误。我仍然可以使用可执行jar运行该程序,但我迫切需要使用Java Web Start。
`Exception in thread "Abandoned connection cleanup thread" java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "setContextClassLoader")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at com.sun.javaws.security.JavaWebStartSecurity.checkPermission(Unknown Source)
at java.lang.Thread.setContextClassLoader(Unknown Source)
at com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:38)
Exception in thread "AWT-EventQueue-2" java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:298)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at dbo.dealSave.user(dealSave.java:364)
at TradeX.uyegiris.jButton1ActionPerformed(uyegiris.java:177)
at TradeX.uyegiris.access$100(uyegiris.java:20)
at TradeX.uyegiris$2.actionPerformed(uyegiris.java:81)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(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" "file.encoding" "read")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at com.sun.javaws.security.JavaWebStartSecurity.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at com.mysql.jdbc.StringUtils.<clinit>(StringUtils.java:70)
... 43 more
`
以下是jnlp文件。对不起,太长了。我可以提供更多信息。
`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="http://192.168.0.162:9999/" href="launch.jnlp" spec="1.0+">
<information>
<title>Unit Elektrik Trader Team</title>
<vendor>seckin.celik</vendor>
<homepage href=""/>
<description>Versiyon 1</description>
<description kind="short">Unit Elektrik Trader Team</description>
<offline-allowed/>
</information>
<update check="background"/>
<resources>
<j2se version="1.7+"/>
<jar href="Trade.jar" main="true"/>
<jar href="lib/jxl.jar"/>
<jar href="lib/swingx-all-1.6.4.jar"/>
<jar href="lib/mysql-connector-java-5.1.23-bin.jar"/>
<jar href="lib/AbsoluteLayout.jar"/>
<jar href="lib/beansbinding-1.2.1.jar"/>
<jar href="lib/antlr-2.7.6.jar"/>
<jar href="lib/cglib-2.2.jar"/>
<jar href="lib/commons-collections-3.1.jar"/>
<jar href="lib/dom4j-1.6.1.jar"/>
<jar href="lib/jta-1.1.jar"/>
<jar href="lib/hibernate-core-3.6.10.Final.jar"/>
<jar href="lib/hibernate-commons-annotations-3.2.0.Final.jar"/>
<jar href="lib/hibernate-entitymanager-3.6.10.Final.jar"/>
<jar href="lib/hibernate-tools-3.6.0.CR1.jar"/>
<jar href="lib/javassist-3.12.0.GA.jar"/>
<jar href="lib/c3p0-0.9.1.jar"/>
<jar href="lib/oscache-2.1.jar"/>
<jar href="lib/slf4j-api-1.6.1.jar"/>
<jar href="lib/slf4j-simple-1.6.1.jar"/>
<jar href="lib/hibernate-jpa-2.0-api-1.0.1.Final.jar"/>
<jar href="lib/dom4j-1.6.1.jar"/>
<jar href="lib/antlr-2.7.6.jar"/>
<jar href="lib/cglib-2.2.jar"/>
<jar href="lib/commons-collections-3.1.jar"/>
<jar href="lib/jta-1.1.jar"/>
<jar href="lib/hibernate-core-3.6.10.Final.jar"/>
<jar href="lib/hibernate-commons-annotations-3.2.0.Final.jar"/>
<jar href="lib/hibernate-entitymanager-3.6.10.Final.jar"/>
<jar href="lib/hibernate-tools-3.6.0.CR1.jar"/>
<jar href="lib/javassist-3.12.0.GA.jar"/>
<jar href="lib/c3p0-0.9.1.jar"/>
<jar href="lib/oscache-2.1.jar"/>
<jar href="lib/slf4j-api-1.6.1.jar"/>
<jar href="lib/slf4j-simple-1.6.1.jar"/>
<jar href="lib/jaxb-impl.jar"/>
<jar href="lib/jaxb-xjc.jar"/>
<jar href="lib/FastInfoset.jar"/>
<jar href="lib/gmbal-api-only.jar"/>
<jar href="lib/ha-api.jar"/>
<jar href="lib/javax.mail_1.4.jar"/>
<jar href="lib/jaxws-rt.jar"/>
<jar href="lib/jaxws-tools.jar"/>
<jar href="lib/management-api.jar"/>
<jar href="lib/mimepull.jar"/>
<jar href="lib/policy.jar"/>
<jar href="lib/saaj-impl.jar"/>
<jar href="lib/stax-ex.jar"/>
<jar href="lib/stax2-api.jar"/>
<jar href="lib/streambuffer.jar"/>
<jar href="lib/woodstox-core-asl.jar"/>
<jar href="lib/jaxws-api.jar"/>
<jar href="lib/jsr181-api.jar"/>
<jar href="lib/javax.annotation.jar"/>
<jar href="lib/saaj-api.jar"/>
<jar href="lib/activation.jar"/>
<jar href="lib/jaxb-api.jar"/>
<jar href="lib/jsr173_1.0_api.jar"/>
</resources>
<application-desc main-class="TradeX.uyegiris">
</application-desc>
</jnlp>`
答案 0 :(得分:2)
如错误所示,您在获得许可时遇到问题
(引起:java.security.AccessControlException:拒绝访问(&#34; java.util.PropertyPermission&#34;&#34; file.encoding&#34;&#34;读&#34;))<登记/>
此外,您错过了JNLP中的安全 -Tag:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8585/" href="Test.jnlp">
<information>
<title>Jnlp Test</title>
<vendor>Test</vendor>
<homepage href="http://localhost:8585/" />
<description>Test</description>
</information>
<security>
<all-permissions/> <!-- SEE HERE FOR EXAMPLE --!>
</security>
<resources>
<j2se version="1.6+" />
<jar href="TestJnlp.jar" />
</resources>
<application-desc main-class="com.test.TestJnlp" />
</jnlp>
重要编辑:
从Java 7u51开始,安全性发生了一些变化!
您可以查看以下内容:
https://blogs.oracle.com/java-platform-group/entry/new_security_requirements_for_rias
Persmission-Info也需要添加到 META-INF / MANIFEST.MF !
答案 1 :(得分:0)
默认情况下,java Web Start应用程序在沙箱(如Applet)中运行。该错误似乎来自缺少读取file.encoding
系统属性的权限。您需要在jnlp中定义应用程序所需的权限级别。添加以下元素应该可以解决您的权限问题。
<security>
<all-permissions/>
</security>