Open
Description
Hello,
I'm quite new to Scala and Redis in general and could use some help. Here is the situation, a friend of mine sadly passed away and we were working on a project together. I did frontend he did backend. As you can imagine I have to do both now for the foreseeable future.
I'm encountering an issue that is very strange, because the application runs fine when using IntelliJ but once I package the application into a jar and try to run it I get an error about redis dispatcher.
Exception in thread "main" java.lang.ExceptionInInitializerError
at JettyLauncher$.main(JettyLauncher.scala:32)
at JettyLauncher.main(JettyLauncher.scala)
Caused by: akka.ConfigurationException: Dispatcher [rediscala.rediscala-client-worker-dispatcher] not configured
at akka.dispatch.Dispatchers.lookupConfigurator(Dispatchers.scala:99)
at akka.dispatch.Dispatchers.lookup(Dispatchers.scala:81)
at redis.RedisClientActorLike.<init>(Redis.scala:35)
at redis.RedisClient.<init>(Redis.scala:85)
at io.onlinebar.commons.store.RedisStore.<init>(RedisStore.scala:15)
at io.onlinebar.Globals$.<init>(Globals.scala:55)
at io.onlinebar.Globals$.<clinit>(Globals.scala)
... 2 more
I don't get the above error when running in IntelliJ, here is how the actual Redis part is setup.
import akka.actor.ActorSystem
import dispatch.StatusCode
import redis.{RedisClient, RedisClientPool, RedisServer}
import scala.concurrent.{ExecutionContext, Future}
class RedisStore(address: String)(implicit actorSystem: ActorSystem) extends KVStore {
implicit val executionContext: ExecutionContext = actorSystem.dispatcher
val pool: RedisClientPool = RedisClientPool(RedisServer(address.split(":")(0), address.split(":")(1).toInt) :: Nil) //Redis server is located on a virtual machine.
//val client: RedisClient = RedisClient()
override def get[T >: Null : Manifest](key: String): Future[T] = pool.get(key).map[T] { item =>
deserializeString[T](item.map({i=>i.utf8String}).getOrElse(throw StatusCode(404)))
}
override def set[T >: Null : Manifest](key: String, item: T, timeToLive: Option[Long] = None): Future[Unit] = pool.set(key, serializeString(item), timeToLive.map( ttl => (System.currentTimeMillis()+ttl)/1000)).map({
case true =>
case false => throw new IllegalStateException(s"Setting $key returned false")
})
override def delete[T >: Null : Manifest](key: String): Future[Unit] = pool.del(key).map({ t => })
}
Scala version 2.11.12 is used.
Any insight would be greatly appreciated.
Thank you.
Metadata
Metadata
Assignees
Labels
No labels