scalaplayframeworklagom

play.application.loader [class java.lang.Class}] does not implement interface play.api.ApplicationLoader or interface play.ApplicationLoader


My service is running fine until I hit api endpoint request with this error-

 Cannot load play.application.loader[play.application.loader [class java.lang.Class}] does not implement interface play.api.ApplicationLoader or interface play.ApplicationLoader.]

my service Loader:-

class LagomPersistentEntityLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext): LagomApplication =
    new LagomPersistentEntityApplication(context)  with AkkaDiscoveryComponents

  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new LagomPersistentEntityApplication(context) with LagomDevModeComponents

  override def describeService: Option[Descriptor] = Some(readDescriptor[LagomTestingEntity])
}

trait UserComponents
  extends LagomServerComponents
    with SlickPersistenceComponents
    with HikariCPComponents
    with AhcWSComponents {

  override lazy val jsonSerializerRegistry: JsonSerializerRegistry = UserSerializerRegistry

  lazy val userRepo: UserRepository = wire[UserRepository]
  readSide.register(wire[UserEventsProcessor])

  clusterSharding.init(
    Entity(UserState.typeKey){ entityContext =>
      UserBehaviour(entityContext)
    }
  )
}

abstract class LagomPersistentEntityApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
    with UserComponents {

  implicit lazy val actorSystemImpl: ActorSystem   = actorSystem
  implicit lazy val ec: ExecutionContext           = executionContext


  override lazy val lagomServer: LagomServer = serverFor[LagomTestingEntity](wire[LagomTestingEntityImpl])

  lazy val bodyParserDefault: Default = wire[Default]

}

application.conf:-

play.application.loader = org.organization.service.LagomTestingEntityImpl

lagom-persistent-entity.cassandra.keyspace = lagom-persistent-entity

cassandra-journal.keyspace = ${lagom-persistent-entity.cassandra.keyspace}

cassandra-snapshot-store.keyspace = ${lagom-persistent-entity.cassandra.keyspace}

lagom.persistent.read-side.cassandra.keyspace = ${lagom-persistent-entity.cassandra.keyspace}

This service has both read side and write side support and If anyone need more info in code then please ask because I really wants to understand where the application is failing.


Solution

  • You should set play.application.loader to the name of your loader class, rather than your persistent entity class:

     play.application.loader = org.organization.service.LagomPersistentEntityLoader
    

    I'm assuming that LagomPersistentEntityLoader is in the same package as LagomTestingEntityImpl. If not, then adjust the fully-qualified class name as needed.