KarelCemus / play-redis

Play framework 2 cache plugin as an adapter to redis-server
Mozilla Public License 2.0
164 stars 44 forks source link

Playframework is crashing, method is abstract #210

Closed mohamed-chit closed 5 years ago

mohamed-chit commented 5 years ago

I am using the following configuration:

play.modules {
    enabled += play.api.cache.redis.RedisCacheModule
}

play {
    cache {
              redis {
                     bind-default = false
                     instances {
                cach_1 {
                                     host: localhost
                                     port: 6379
                                     prefix: default
                               }
                               cache_2 {
                                      host: localhost
                                      port: 6379
                                      prefix: emailusers
                                }
                       }
               }
    }
}

java code:

package presistency;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import objects.EmailUser;
import play.cache.NamedCache;
import play.cache.SyncCacheApi;

import javax.validation.constraints.NotNull;
import java.util.Optional;

@Singleton
public class UserObjectCache {

    private final int USER_OBJECT_EXPIRATION_TIME_In_SECONDS = 60*3;

    @Inject
    @NamedCache("cache_1")
    SyncCacheApi userCache;

    public void insert(@NotNull  UserObject  userObject) {
        this.userCache.set( userObject.email,  userObject, USER_OBJECT_EXPIRATION_TIME_In_SECONDS);
    }

    public Optional< UserObject> getOptional(@NotNull String email) {
        return userCache.getOptional(email);
    }

    public void remove( @NotNull  UserObject  userObject ) {
        userCache.remove( userObject.email);
    }
}

but i get the following error:

Uncaught error from thread [application-akka.actor.default-dispatcher-6]: Method play/api/cache/redis/impl/JavaRedis.getOptional(Ljava/lang/String;)Ljava/util/concurrent/CompletionStage; is abstract, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application]
java.lang.AbstractMethodError: Method play/api/cache/redis/impl/JavaRedis.getOptional(Ljava/lang/String;)Ljava/util/concurrent/CompletionStage; is abstract
    at play.api.cache.redis.impl.JavaRedis.getOptional(JavaRedis.scala)
    at play.cache.DefaultSyncCacheApi.getOptional(DefaultSyncCacheApi.java:43)
    at caches.EmailUserCache.getOptional(EmailUserCache.java:34)
    at dataproviders.EmailUserDataProvider.get(EmailUserDataProvider.java:42)
    at controllers.DatabaseController.get(DatabaseController.java:51)
    at router.Routes$$anonfun$routes$1.$anonfun$applyOrElse$21(Routes.scala:321)
    at play.core.routing.HandlerInvokerFactory$$anon$9.resultCall(HandlerInvoker.scala:144)
    at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$3$$anon$4$$anon$5.invocation(HandlerInvoker.scala:109)
    at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:90)
    at play.mvc.Action.lambda$call$0(Action.java:84)
    at java.util.Optional.map(Optional.java:215)
    at play.mvc.Action.call(Action.java:79)
    at play.http.DefaultActionCreator$1.call(DefaultActionCreator.java:32)
    at play.core.j.JavaAction.$anonfun$apply$8(JavaAction.scala:140)
    at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:658)
    at scala.util.Success.$anonfun$map$1(Try.scala:255)
    at scala.util.Success.map(Try.scala:213)
    at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
    at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
    at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
    at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:67)
    at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:71)
    at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:59)
    at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:72)
    at scala.concurrent.impl.Promise$KeptPromise$Kept.onComplete(Promise.scala:372)
    at scala.concurrent.impl.Promise$KeptPromise$Kept.onComplete$(Promise.scala:371)
    at scala.concurrent.impl.Promise$KeptPromise$Successful.onComplete(Promise.scala:379)
    at scala.concurrent.impl.Promise.transform(Promise.scala:33)
    at scala.concurrent.impl.Promise.transform$(Promise.scala:31)
    at scala.concurrent.impl.Promise$KeptPromise$Successful.transform(Promise.scala:379)
    at scala.concurrent.Future.map(Future.scala:292)
    at scala.concurrent.Future.map$(Future.scala:292)
    at scala.concurrent.impl.Promise$KeptPromise$Successful.map(Promise.scala:379)
    at scala.concurrent.Future$.apply(Future.scala:658)
    at play.core.j.JavaAction.apply(JavaAction.scala:140)
    at play.api.mvc.Action.$anonfun$apply$2(Action.scala:97)
    at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
    at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
    at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
    at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
    at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
    at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
[error] a.a.ActorSystemImpl - Uncaught error from thread [application-akka.actor.default-dispatcher-6]: Method play/api/cache/redis/impl/JavaRedis.getOptional(Ljava/lang/String;)Ljava/util/concurrent/CompletionStage; is abstract, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application]
java.lang.AbstractMethodError: Method play/api/cache/redis/impl/JavaRedis.getOptional(Ljava/lang/String;)Ljava/util/concurrent/CompletionStage; is abstract
    at play.api.cache.redis.impl.JavaRedis.getOptional(JavaRedis.scala)
    at play.cache.DefaultSyncCacheApi.getOptional(DefaultSyncCacheApi.java:43)
    at caches.EmailUserCache.getOptional(EmailUserCache.java:34)
    at dataproviders.EmailUserDataProvider.get(EmailUserDataProvider.java:42)
    at controllers.DatabaseController.get(DatabaseController.java:51)
    at router.Routes$$anonfun$routes$1.$anonfun$applyOrElse$21(Routes.scala:321)
    at play.core.routing.HandlerInvokerFactory$$anon$9.resultCall(HandlerInvoker.scala:144)
    at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$3$$anon$4$$anon$5.invocation(HandlerInvoker.scala:109)
    at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:90)
    at play.mvc.Action.lambda$call$0(Action.java:84)
KarelCemus commented 5 years ago

What is your version of Play and play-redis?

KarelCemus commented 5 years ago

Any progress on this issue? Could you supply more details about versions and your configuration?

KarelCemus commented 5 years ago

Issue is not specific, there is no response and it looks more like a configuration issue in the project.

Closing for now.

If anyone encounters a similar issue in future, feel free to report it and reopen it.