JavaFX应用程序中的AccessControlException

时间:2013-02-04 13:25:28

标签: java web-applications javafx-2 accesscontrolexception

我正在尝试在网页中嵌入Java FX音乐播放器。此JavaFX应用程序在Web启动模式下运行良好。但是,当我尝试在Web模式下运行它或尝试在构建后访问其网页时,它会给我AccessControlException。错误信息是这样的:

    Match: beginTraversal
Match: digest selected JREDesc: JREDesc[version 1.6+, heap=-1--1, args=null, href=http://java.sun.com/products/autodl/j2se, sel=false, null, null], JREInfo: JREInfo for index 0:
    platform is: 1.7
    product is: 1.7.0_13
    location is: http://java.sun.com/products/autodl/j2se
    path is: C:\Program Files\Java\jre7\bin\javaw.exe
    args is: null
    native platform is: Windows, x86 [ x86, 32bit ]
    JavaFX runtime is: JavaFX 2.2.5 found at C:\Program Files\Java\jre7\
    enabled is: true
    registered is: true
    system is: true

    Match: ignoring maxHeap: -1
    Match: ignoring InitHeap: -1
    Match: digesting vmargs: null
    Match: digested vmargs: [JVMParameters: isSecure: true, args: ]
    Match: JVM args after accumulation: [JVMParameters: isSecure: true, args: ]
    Match: digest LaunchDesc: file:/C:/Users/lenovo/Documents/NetBeansProjects/MusicPlay/dist/MusicPlay.jnlp
    Match: digest properties: []
    Match: JVM args: [JVMParameters: isSecure: true, args: ]
    Match: endTraversal ..
    Match: JVM args final: 
    Match: Running JREInfo Version    match: 1.7.0.13 == 1.7.0.13
     Match: Running JVM args match: have:<>  satisfy want:<>
java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.dir" "read")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at java.io.Win32FileSystem.getUserPath(Unknown Source)
    at java.io.Win32FileSystem.resolve(Unknown Source)
    at java.io.File.getAbsolutePath(Unknown Source)
    at java.io.File.getAbsoluteFile(Unknown Source)
    at java.io.File.toURI(Unknown Source)
    at musicplay.MusicPlay.start(MusicPlay.java:90)
    at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:131)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
    at java.lang.Thread.run(Unknown Source)
CacheEntry[file:/C:/Users/lenovo/Documents/NetBeansProjects/MusicPlay/dist/MusicPlay.jnlp]: updateAvailable=true,lastModified=Mon Feb 04 18:25:32 IST 2013,length=948
CacheEntry[file:/C:/Users/lenovo/Documents/NetBeansProjects/MusicPlay/dist/MusicPlay.jnlp]: updateAvailable=true,lastModified=Mon Feb 04 18:25:32 IST 2013,length=948
CacheEntry[file:/C:/Users/lenovo/Documents/NetBeansProjects/MusicPlay/dist/MusicPlay.jar]: updateAvailable=false,lastModified=Mon Feb 04 18:46:10 IST 2013,length=31879
Java Plug-in 10.13.2.20
Using JRE version 1.7.0_13-b20 Java HotSpot(TM) Client VM
User home directory = C:\Users\lenovo
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

我已尝试通过授予以下权限来编辑.java.policy文件

    grant codeBase "file:*" {
        permission java.security.AllPermission;
};

但它仍然给了我同样的信息。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我自己找到了答案。 在Web页面中嵌入JavaFX应用程序时。您的应用程序(或Web页面)不允许访问本地文件结构。我以前也试过这样做。我正在传递歌曲文件的路径。 但实际上您需要将您的媒体文件托管在某些服务器目录中,例如Apache Server目录。网页可以轻松访问Apache Server Directory。您需要将媒体文件的URI传递到您的应用程序中。 示例currentFile="http://localhost/songs/Jaane_Kaise.mp3";