Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError on akka.persistence.Persistence.journalFor private API #27

Open
dgouyette opened this issue Oct 12, 2018 · 2 comments

Comments

@dgouyette
Copy link

dgouyette commented Oct 12, 2018

Hello,

I prepare a workshop on akka-persistence (Code is available here : https://github.com/dgouyette/workshop-akka-persistence )

When i use the ReadJournal :

    val readJournal = PersistenceQuery(actorSystem).readJournalFor[PostgresReadJournal](PostgresReadJournal.Identifier).eventsByPersistenceId("", 0, Long.MaxValue)
    val readJournalAsJsValue = readJournal.map( _.event).collect{case e : BoardEvent=>  Json.parse(eventJsonEncoder.toJson(e).value)   }
    Flow.fromSinkAndSource(Sink.ignore, readJournalAsJsValue)
  }

I got the following exception :

a.a.OneForOneStrategy - head of empty list
java.util.NoSuchElementException: head of empty list
	at scala.collection.immutable.Nil$.head(List.scala:428)
	at scala.collection.immutable.Nil$.head(List.scala:425)
	at akka.actor.ActorCell.receiveMessage(ActorCell.scala:588)
	at akka.actor.ActorCell.invoke(ActorCell.scala:557)
	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:258)
	at akka.dispatch.Mailbox.run(Mailbox.scala:225)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:235)
	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)
java.lang.NoSuchMethodError: akka.persistence.Persistence.journalFor(Ljava/lang/String;)Lakka/actor/ActorRef;
	at akka.persistence.pg.journal.query.BaseEventsPublisher.<init>(BaseEventsPublisher.scala:31)
	at akka.persistence.pg.journal.query.LiveEventsByPersistenceIdPublisher.<init>(LiveEventsByPersistenceIdPublisher.scala:15)
	at akka.persistence.pg.journal.query.package$EventsByPersistenceIdPublisher$.$anonfun$props$3(package.scala:44)
	at akka.actor.TypedCreatorFunctionConsumer.produce(IndirectActorProducer.scala:87)
	at akka.actor.Props.newActor(Props.scala:212)
	at akka.actor.ActorCell.newActor(ActorCell.scala:624)
	at akka.actor.ActorCell.create(ActorCell.scala:650)
	at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:523)
	at akka.actor.ActorCell.systemInvoke(ActorCell.scala:545)
	at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:283)
	at akka.dispatch.Mailbox.run(Mailbox.scala:224)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:235)
	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)

Persistence(context.system).journalFor(writeJournalPluginId) is a private API.

Is there a workaround ?
i use :

  • akka 2.5.14
  • akka-persistence-pg 0.10.0
  • Scala 2.12
@kwark
Copy link
Contributor

kwark commented Oct 13, 2018

It looks like you are on akka 2.5.13 instead of 2.5.14 => https://github.com/dgouyette/workshop-akka-persistence/blob/master/build.sbt#L9

I'll check if we can replace calling the private API with something else

@dgouyette
Copy link
Author

Thanks for you answer 👍
I made tests with versions from 2.5.10 to 2.5.17, same error.
Do you know if i can use a workaround ?

I replaced
val journal: ActorRef = Persistence(context.system).journalFor(writeJournalPluginId)
by
val journal: ActorRef = PersistenceQuery(context.system).readJournalFor(writeJournalPluginId)

But it doesn't work. :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants