Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

JedisPool injection giving exception for Play with java 2.4.x #156

Open
guptamitesh opened this issue Jul 8, 2015 · 5 comments
Open

JedisPool injection giving exception for Play with java 2.4.x #156

guptamitesh opened this issue Jul 8, 2015 · 5 comments

Comments

@guptamitesh
Copy link

Hi,
I am using play for java 2.4.x. I followed all the steps to step the redis plugin and it worked out pretty well. However, while using the injected dependency for jedis pool:

import javax.inject.Inject;
import redis.clients.jedis.JedisPool;
@Inject JedisPool jedisPool;

I am getting the following error:

Unexpected exception

ProvisionException: Unable to provision, see the following errors:

  1. Could not find a suitable constructor in redis.clients.jedis.JedisPool. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
    at redis.clients.jedis.JedisPool.class(JedisPool.java:10)
    while locating redis.clients.jedis.JedisPool
    for field at controllers.AdminLoginController.jedisPool(AdminLoginController.java:22)
    while locating controllers.AdminLoginController
    for parameter 13 at router.Routes.(Routes.scala:76)
    while locating router.Routes
    while locating play.api.inject.RoutesProvider
    while locating play.api.routing.Router

1 error
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1025) ~[guice-4.0.jar:na]
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051) ~[guice-4.0.jar:na]
at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:321) ~[play_2.11-2.4.0.jar:2.4.0]
at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:316) ~[play_2.11-2.4.0.jar:2.4.0]
at play.api.Application$class.routes(Application.scala:111) ~[play_2.11-2.4.0.jar:2.4.0]
at play.api.DefaultApplication.routes(Application.scala:240) ~[play_2.11-2.4.0.jar:2.4.0]
at play.api.Play$.start(Play.scala:89) ~[play_2.11-2.4.0.jar:2.4.0]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:156) ~[play-server_2.11-2.4.0.jar:2.4.0]
... 15 common frames omitted

@ronaldwidha
Copy link

I'm getting the same issue too. I can see that the plugin is based on Jedis 2.4.2 which doesn't have a zero-argument constructor. 2.7 and above have that. I suspect this isn't the root issue though. It almost look as if I may have not configured the redis.host or url properly so that it doesn't get injected through. Is this correct?

@ronaldwidha
Copy link

I'm hitting my head against a wall, cannot seem to work out the solution. Any ideas what we may have done wrong? or is it a genuine bug?

@ronaldwidha
Copy link

Worked out what it is for me. readme.md is outdated.
the module version is 2.4.1 not 2.4.0

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs,
  "com.typesafe.play.modules" %% "play-modules-redis" % "2.4.1"
)

tested on Play 2.4.2

@MiteshSharma
Copy link

nice, it worked fine with 2.4.1 play-module-redis.
Are you able to get JedisPool injected in Akka Actor or in model class? JedisPool injection is working only for controller class.

@ronaldwidha
Copy link

@MiteshSharma yes I get that to work, see this post for more info

ronaldwidha added a commit to ronaldwidha/play-plugins that referenced this issue Jul 17, 2015
For Play 2.4.2, the current readme causes an exception to be thrown upon setting up @Inject on JedisPool. The correct dependency is play-plugin-redis 2.4.1 see playframework#156 and playframework#157
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants