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

NoSuchElementException after creating a user #144

Closed
TimMoore opened this issue Aug 8, 2017 · 3 comments
Closed

NoSuchElementException after creating a user #144

TimMoore opened this issue Aug 8, 2017 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@TimMoore
Copy link
Contributor

TimMoore commented Aug 8, 2017

Reproduction

  1. Checkout master of online-auction-java.
  2. sbt 'set lagomCassandraCleanOnStart in ThisBuild := true' runAll (to start from a fresh database)
  3. Open http://localhost:9000/
  4. Click "Create user" in the header
  5. Enter values for all fields and click the "Create user"

Result

In the UI:

Execution exception

[CompletionException: java.util.NoSuchElementException: No value present]

In the console:

[error] application - 

! @750hg040p - Internal server error, for (GET) [/my/items/created] ->
 
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[CompletionException: java.util.NoSuchElementException: No value present]]
	at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:293)
	at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:220)
	at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
	at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
	at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:100)
	at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
	at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
	at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346)
	at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
Caused by: java.util.concurrent.CompletionException: java.util.NoSuchElementException: No value present
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
	at java.util.concurrent.CompletableFuture.biApply(CompletableFuture.java:1107)
	at java.util.concurrent.CompletableFuture$BiApply.tryFire(CompletableFuture.java:1070)
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442)
	at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:56)
	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
	at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:415)
	at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
Caused by: java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Optional.java:135)
	at views.html.myItems_Scope0$myItems_Scope1$myItems.apply(myItems.template.scala:41)
	at views.html.myItems_Scope0$myItems_Scope1$myItems.render(myItems.template.scala:110)
	at views.html.myItems.render(myItems.template.scala)
	at controllers.ProfileController.lambda$null$0(ProfileController.java:48)
	at java.util.concurrent.CompletableFuture.biApply(CompletableFuture.java:1105)
	at java.util.concurrent.CompletableFuture$BiApply.tryFire(CompletableFuture.java:1070)
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442)
	at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:56)
	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
@TimMoore TimMoore added the bug Something isn't working label Aug 8, 2017
@TimMoore
Copy link
Contributor Author

TimMoore commented Aug 8, 2017

The user is actually created: the issue is just that an error appears on the next page. If you reload the page after 10 seconds (the eventual consistency delay) then it loads successfully.

@TimMoore
Copy link
Contributor Author

TimMoore commented Aug 8, 2017

I think I understand the problem: the user repository is eventually consistent. This page assumes the user will be available immediately. This is related to the change in #143, but I think we want to take a different approach, and make a userService.getUser(id) call to retrieve the details for the currently logged-in user.

@TimMoore
Copy link
Contributor Author

Fixed by #143

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants