Question

I am trying to embed a Java FX Music Player in a web page. This JavaFX application runs fine in web start mode. But when I am trying to run it in web mode or trying to access its webpage after build, it gives me AccessControlException. Error message is something like this:

    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>
----------------------------------------------------

I have tried editing .java.policy file by granting following permission

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

But it still gives me the same message. Any help will be appreciated.

Was it helpful?

Solution

I found the answer myself. When you are embedding a JavaFX application in a web page. Your appplication(or Web Page) is not permitted to access the local file structure. I was previously trying to do the same. I was passing the path of song file. But actually you need to host your media file in some server directory such as Apache Server directory. A web page can easily access Apache Server Directory. You need to pass the URI of the media file into your application. Example currentFile="http://localhost/songs/Jaane_Kaise.mp3";

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top