SerhatCan
SerhatCan

Reputation: 590

No implementation for play.cache.CacheApi annotated with @play.cache.NamedCache(value=session-cache) was bound on Production

I'm using @NamedCache annotation without any problem in dev mode by using activator run. I've specified caches other than default cache called play in application.conf file as play.cache.bindCaches = ["user-cache", "session-cache"]. This works fine without any problem as I've checked getting named cache by using CacheManager.

However, in production mode. I'm using activator dist command. Then, unzip created created snapshot found in target\universal\project-name address.After that I'm using java -Dhttp.port=9000 -Dconfig.resource=application.conf -cp "../lib/*;../conf" play.core.server.ProdServerStart command to start application in production mode.

When I use @NamedCache annotation in production it gives error:

1) No implementation for play.cache.CacheApi annotated with @play.cache.NamedCache(value=session-cache) was bound.
while locating play.cache.CacheApi annotated with @play.cache.NamedCache(value=session-cache)
for field at services.space.SessionSpace.cache(SessionSpace.java:19)
while locating services.space.SessionSpace
for field at services.SecurityService.sessionSpace(SecurityService.java:21)
while locating services.SecurityService
for field at common.Response.securityService(Response.java:17)
while locating common.Response
for field at controllers.BaseController.response(BaseController.java:53)
while locating controllers.Application
for parameter 2 at router.Routes.<init>(Routes.scala:60)
while locating router.Routes
while locating play.api.inject.RoutesProvider
while locating play.api.routing.Router

After getting this error, I've removed NamedCache's and used default cache. When I do that, everything works fine. Again, in dev mode NamedCache works as expected.

Upvotes: 2

Views: 1493

Answers (1)

Mani Kuramboyina
Mani Kuramboyina

Reputation: 11

I was encountering similar problem. But in my case I was injecting the cache api which i use in one of my project dependencies (which was also developed by me). I learnt that the mistake was any application.conf inside you project dependencies will be overwritten. i.e conf/appliaction.conf will override all the other application.conf's if you are using a dependency which was developmed in play. Solution: All your application.confs must be named as reference.conf inside your dependencies. Are you using the cache in one of your dependencies?

Cheers, Mani.

Upvotes: 1

Related Questions