Improved error handling and message for Config
This commit is contained in:
parent
78d1651a0f
commit
1cc28c8df6
2 changed files with 19 additions and 14 deletions
|
|
@ -8,6 +8,8 @@ import se.scalablesolutions.akka.util.Logging
|
|||
|
||||
import net.lag.configgy.{Configgy, ParseException}
|
||||
|
||||
class ConfigurationException(message: String) extends RuntimeException(message)
|
||||
|
||||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
|
|
@ -34,16 +36,18 @@ object Config extends Logging {
|
|||
Configgy.configure(configFile)
|
||||
log.info("Config loaded from -Dakka.config=%s", configFile)
|
||||
} catch {
|
||||
case e: ParseException => throw new IllegalStateException(
|
||||
"Config could not be loaded from -Dakka.config=" + configFile)
|
||||
case e: ParseException => throw new ConfigurationException(
|
||||
"Config could not be loaded from -Dakka.config=" + configFile +
|
||||
"\n\tdue to: " + e.toString)
|
||||
}
|
||||
} else if (getClass.getClassLoader.getResource("akka.conf") != null) {
|
||||
try {
|
||||
Configgy.configureFromResource("akka.conf", getClass.getClassLoader)
|
||||
log.info("Config loaded from the application classpath.")
|
||||
} catch {
|
||||
case e: ParseException => throw new IllegalStateException(
|
||||
"Can't load 'akka.conf' config file from application classpath.")
|
||||
case e: ParseException => throw new ConfigurationException(
|
||||
"Can't load 'akka.conf' config file from application classpath," +
|
||||
"\n\tdue to: " + e.toString)
|
||||
}
|
||||
} else if (HOME.isDefined) {
|
||||
try {
|
||||
|
|
@ -51,12 +55,13 @@ object Config extends Logging {
|
|||
Configgy.configure(configFile)
|
||||
log.info("AKKA_HOME is defined as [%s], config loaded from [%s].", HOME.get, configFile)
|
||||
} catch {
|
||||
case e: ParseException => throw new IllegalStateException(
|
||||
case e: ParseException => throw new ConfigurationException(
|
||||
"AKKA_HOME is defined as [" + HOME.get + "] " +
|
||||
"but the 'akka.conf' config file can not be found at [" + HOME.get + "/config/akka.conf].")
|
||||
"\n\tbut the 'akka.conf' config file can not be found at [" + HOME.get + "/config/akka.conf]," +
|
||||
"\n\tdue to: " + e.toString)
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
throw new ConfigurationException(
|
||||
"\nCan't load 'akka.conf'." +
|
||||
"\nOne of the three ways of locating the 'akka.conf' file needs to be defined:" +
|
||||
"\n\t1. Define the '-Dakka.config=...' system property option." +
|
||||
|
|
@ -69,7 +74,7 @@ object Config extends Logging {
|
|||
}
|
||||
|
||||
val CONFIG_VERSION = config.getString("akka.version", "0")
|
||||
if (VERSION != CONFIG_VERSION) throw new IllegalStateException(
|
||||
if (VERSION != CONFIG_VERSION) throw new ConfigurationException(
|
||||
"Akka JAR version [" + VERSION + "] is different than the provided config ('akka.conf') version [" + CONFIG_VERSION + "]")
|
||||
val startTime = System.currentTimeMillis
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
provider = "from-jndi" # Options: "from-jndi" (means that Akka will try to detect a TransactionManager in the JNDI)
|
||||
# "atomikos" (means that Akka will use the Atomikos based JTA impl in 'akka-jta',
|
||||
# e.g. you need the akka-jta JARs on classpath).
|
||||
self.timeout = 60000
|
||||
timeout = 60000
|
||||
</jta>
|
||||
|
||||
<rest>
|
||||
|
|
@ -53,12 +53,12 @@
|
|||
authenticator = "sample.security.BasicAuthenticationService" # The authentication service to use. Need to be overridden (uses sample now)
|
||||
|
||||
#IF you are using a KerberosAuthenticationActor
|
||||
# <kerberos>
|
||||
# servicePrincipal = "HTTP/localhost@EXAMPLE.COM"
|
||||
# keyTabLocation = "URL to keytab"
|
||||
# kerberosDebug = "true"
|
||||
# <kerberos>
|
||||
# servicePrincipal = "HTTP/localhost@EXAMPLE.COM"
|
||||
# keyTabLocation = "URL to keytab"
|
||||
# kerberosDebug = "true"
|
||||
# realm = "EXAMPLE.COM"
|
||||
# </kerberos>
|
||||
# </kerberos>
|
||||
</rest>
|
||||
|
||||
<remote>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue