No class found error for com.mohiva.play.silhouette.api.LoginInfo for play 2.5.x


#1

We recently migrated out project from play 2.4.x to 2.5.10 . We got the below run time errors . Do we need to update anything wrt silhouette for play 2.5.x. Currently we use 3.0.0 version for our project

“com.mohiva” %% “play-silhouette” % “3.0.0”

1) Error injecting constructor, java.lang.NoClassDefFoundError: Could not initialize class com.mohiva.play.silhouette.a
pi.LoginInfo$
  at schema.UserDAOImpl.<init>(UserDAO.scala:84)
  while locating schema.UserDAOImpl
  while locating schema.UserDAO
    for parameter 1 at schema.UserSupervisorDAOImpl.<init>(UserSupervisorDAO.scala:79)
  while locating schema.UserSupervisorDAOImpl
  while locating schema.UserSupervisorDAO
    for parameter 2 at actors.PostSignUpHandler.<init>(PostSignUpHandler.scala:25)
  while locating actors.PostSignUpHandler
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mohiva.play.silhouette.api.LoginInfo$
        at schema.FormatWrapper$class.$init$(FormatWrapper.scala:16)
        at schema.UserDAOImpl.<init>(UserDAO.scala:89)
        at schema.UserDAOImpl$$FastClassByGuice$$f1ce499a.newInstance(<generated>)
        at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
        at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.jav
a:61)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:756)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:756)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
        at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
        at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:405)
        at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:400)
        at play.api.libs.concurrent.ActorRefProvider$$anonfun$1.apply(Akka.scala:210)
        at play.api.libs.concurrent.ActorRefProvider$$anonfun$1.apply(Akka.scala:210)
        at akka.actor.TypedCreatorFunctionConsumer.produce(IndirectActorProducer.scala:87)
        at akka.actor.Props.newActor(Props.scala:213)
        at akka.actor.ActorCell.newActor(ActorCell.scala:562)
        at akka.actor.ActorCell.create(ActorCell.scala:588)
        at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:461)
        at akka.actor.ActorCell.systemInvoke(ActorCell.scala:483)
        at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
        at akka.dispatch.Mailbox.run(Mailbox.scala:223)
        at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

2) Error injecting constructor, java.lang.NoClassDefFoundError: Could not initialize class com.mohiva.play.silhouette.a
pi.LoginInfo$
  at schema.UserDAOImpl.<init>(UserDAO.scala:84)
  while locating schema.UserDAOImpl
  while locating schema.UserDAO
    for parameter 2 at schema.authorization.UserRoleDAOImpl.<init>(UserRoleDAO.scala:80)
  while locating schema.authorization.UserRoleDAOImpl
  while locating schema.authorization.UserRoleDAO
    for parameter 2 at schema.UserSupervisorDAOImpl.<init>(UserSupervisorDAO.scala:79)
  while locating schema.UserSupervisorDAOImpl
  while locating schema.UserSupervisorDAO
    for parameter 2 at actors.PostSignUpHandler.<init>(PostSignUpHandler.scala:25)
  while locating actors.PostSignUpHandler
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mohiva.play.silhouette.api.LoginInfo$
        at schema.FormatWrapper$class.$init$(FormatWrapper.scala:16)
        at schema.UserDAOImpl.<init>(UserDAO.scala:89)
        at schema.UserDAOImpl$$FastClassByGuice$$f1ce499a.newInstance(<generated>)
        at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
        at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.jav
a:61)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:756)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:756)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:756)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
        at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
        at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:405)
        at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:400)
        at play.api.libs.concurrent.ActorRefProvider$$anonfun$1.apply(Akka.scala:210)
        at play.api.libs.concurrent.ActorRefProvider$$anonfun$1.apply(Akka.scala:210)
        at akka.actor.TypedCreatorFunctionConsumer.produce(IndirectActorProducer.scala:87)
        at akka.actor.Props.newActor(Props.scala:213)
        at akka.actor.ActorCell.newActor(ActorCell.scala:562)
        at akka.actor.ActorCell.create(ActorCell.scala:588)
        at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:461)
        at akka.actor.ActorCell.systemInvoke(ActorCell.scala:483)
        at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
        at akka.dispatch.Mailbox.run(Mailbox.scala:223)
        at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)



#2

Hi,

you must switch to silhouette 4.0.0 for Play 2.5.

Best regards,
Christian


#3

Thanks Chris
I started migration to 4.0.0 , but encountered few errors

 restAuthenticator {
    authenticatorIdleTimeout = 60 minutes
    authenticatorExpiry = 12 hours
    sharedSecret = ${play.crypto.secret}
  }
@Provides
  def provideBearerAuthenticatorService(fingerprintGenerator: FingerprintGenerator,
                                     idGenerator: IDGenerator,
                                     authenticatorDAO: AuthenticatorRepository[BearerTokenAuthenticator],
                                     configuration: Configuration,
                                     clock: Clock): AuthenticatorService[BearerTokenAuthenticator] = {
    val config = configuration.underlying.as[BearerTokenAuthenticatorSettings]("silhouette.restAuthenticator")
    new BearerTokenAuthenticatorService(config, authenticatorDAO, idGenerator, clock)
  }

The above code throws an error at this particular line
val config = configuration.underlying.asBearerTokenAuthenticatorSettings

[error] E:\Yantranet\DevZone\SignwareSecurity\app\modules\authentication\AuthenticationModule.scala:142: Cannot generate a config value reader for type Option[Option[Seq[com.mohiva.play.silhouette.api.util.RequestPart.Value]]], because value readers cannot be auto-generated for types with type parameters. Consider defining your own ValueReader[Option[Option[Seq[com.mohiva.play.silhouette.api.util.RequestPart.Value]]]]
[error]     val config = configuration.underlying.as[BearerTokenAuthenticatorSettings]("silhouette.restAuthenticator")
[error]

I am not clear as of why is it considering
Option[Option[Seq[com.mohiva.play.silhouette.api.util.RequestPart.Value]]] instead of Option[Seq[com.mohiva.play.silhouette.api.util.RequestPart.Value]] for BearerTokenAuthenticatorSettings

Can you help us resolving this . Thanks in advance


#4

Hi,

You must include the ficus reader for enumerations. Please see the ficus documentation.

Best regards,
Christian