Pregunta

I have created an applet for recording sound. It throws an exception when I try to open a dataline.

TargetDataLine.open()

java.security.AccessControlException: access denied (javax.sound.sampled.AudioPermission record)

My applet is self signed, all other jar files are self signed.

Previously I was using a different thread to start the TargetDataLine and close the line. Afterwords instead of creating another thread, I switched to Executorservice. It works fine with thread but throws above exception with ExecutorService.

¿Fue útil?

Solución

Since the executor service starts a new thread when there is call from javascript, the security level of the thread is set to that of javascript thread.

So using AccessControl.doPrivilaged helps to solve the problem.Explained here how to do it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top