You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
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:
/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]")
}
}
This issue looks related to recently closed issues: #3632 scala.util.properties.versionString doesn't work in applets #94: Security exception upon Actors library initialization.
Please let me know if you need any additional information.
Thanks!
Sam
The text was updated successfully, but these errors were encountered:
@paulp said:
We don't have the resources to play whack-a-mole and solving the general issue requires improved infrastructure for abstracting over different operating environments. It's desirable, no question. I'm closing related issue #3519 and pointing it here.
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]")
}
}
This issue looks related to recently closed issues:
#3632 scala.util.properties.versionString doesn't work in applets
#94: Security exception upon Actors library initialization.
Please let me know if you need any additional information.
Thanks!
Sam
The text was updated successfully, but these errors were encountered: