SecurityException when running App in Java Web Start sandbox

12 views
Skip to first unread message

Sam Reid

unread,
Jun 24, 2011, 1:16:09 AM6/24/11
to scala-language
I recently rewrote one of my Scala applications to use App, and it
worked great in my development environment. However, when we deployed
it under Web Start, it crashed with a Java Web Start Error: access
denied (java.util.PropertyPermission scala.time read). Here is the
top of the stack trace:

java.security.AccessControlException: access denied
(java.util.PropertyPermission scala.time 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 scala.util.PropertiesTrait$class.propIsSet(Properties.scala:44)
at scala.App$class.main(App.scala:61)
at
edu.colorado.phet.motionseries.sims.rampforcesandmotion.RampForcesAndMotionApplication
$.main(RampForcesAndMotionApplication.scala:123)
........

The Java Web Start console prints this:

#### Java Web Start Error:
#### access denied (java.util.PropertyPermission scala.time read)

The source code for App.scala on lampsvn here:
http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk/src/library/scala/App.scala

shows that main is implemented like this:

def main(args: Array[String]) = {
this._args = args
for (proc <- initCode) proc()
if (util.Properties.propIsSet("scala.time")) {
val total = currentTime - executionStart
Console.println("[total " + total + "ms]")
}
}

Can App.main be rewritten to check for permission to read this system
property, or alternatively try/catching the AccessControlException (or
maybe there is a better Scala way for handling this issue)? Without a
fix for this, I don't think we will be able to use App for any of our
production Scala applications since they run in the Java Web Start
sandbox. I haven't tested it, but maybe the former solution would
look something like this:

def main(args: Array[String]) = {
this._args = args
for ( proc <- initCode ) {
proc()
}

/*If we have the permission to check the "scala.time" property, do
so and print the time the application took to start up.
Permission checks are necessary because Java Web Start's
SecurityManager (and possibly others) will not grant permission
to read the "scala.time" property.*/
val scalaTimePropertyKey = "scala.time"
val permissionToRead = if ( System.getSecurityManager != null ) {
try {
System.getSecurityManager.checkPermission(new
PropertyPermission(scalaTimePropertyKey, "read"))
true
}
catch {
case _ => false
}
}
if ( permissionToRead &&
util.Properties.propIsSet(scalaTimePropertyKey) ) {
val total = currentTime - executionStart
Console.println("[total " + total + "ms]")
}
}

Please let me know if you'd prefer that I post this request on a
different mailing list or in a bug/feature tracker.

Thanks!
Sam

Martin Odersky

unread,
Jun 24, 2011, 11:02:51 AM6/24/11
to scala-l...@googlegroups.com, scala-language
It would be best to file a ticket on Jura for this.

thanks

Martin

Sent from my phone

Sam Reid

unread,
Jun 24, 2011, 11:37:32 AM6/24/11
to scala-l...@googlegroups.com
I created JIRA ticket SI-4734 for this issue:

Thanks!
Sam
Reply all
Reply to author
Forward
0 new messages