This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Security exception when using resource-url in an applet


I'm trying to load a text file from an applet. I've put the text file into
the same .jar file as the applet. I'm planning to use resource-url to get
the URL of the file, and then open-input-file with the URL, but at this
point all I'm doing is getting the URL.

Here's my .scm file:

;-- start applettest.scm --
(define (init) :: void
  (format #t "called init.~%~!"))

(define (start) <void>
  (format #t "called start.~%~!")
  (resource-url "hello.txt"))

(define (stop) :: void (format #t "called stop.~%~!"))
(define (destroy) :: void (format #t "called destroy.~%~!"))

;-- end applettest.scm --

However, I get the following exception when I call (resource-url
"hello.txt"):

$ appletviewer applettest.html
java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)
    at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:785)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:714)
    at sun.applet.AppletPanel.run(AppletPanel.java:368)
    at java.lang.Thread.run(Thread.java:637)
Caused by: java.security.AccessControlException: access denied
(java.net.NetPermission specifyStreamHandler)
    at 
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:323)
    at 
java.security.AccessController.checkPermission(AccessController.java:546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at java.net.URL.checkSpecifyHandler(URL.java:629)
    at java.net.URL.<init>(URL.java:501)
    at gnu.text.ResourceStreamHandler.makeURL(ResourceStreamHandler.java:56)
    at gnu.text.URLPath.classResourcePath(URLPath.java:147)
    at applettest.<clinit>(applettest.scm)
    ... 10 more

I'm not sure why there's a security exception, as the text file is inside
the same .jar file as the applet. Has anyone had experience using
resource-url to get the path to a file contained in a .jar file? Am I
missing something?

thanks,
Alex



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]