ochrons / scalajs-spa-tutorial

Tutorial for creating a simple Single Page Application in ScalaJS
Apache License 2.0
672 stars 229 forks source link

Failed to add new constructs #23

Closed MikaelMayer closed 9 years ago

MikaelMayer commented 9 years ago

Steps to reproduce

I added a new method for API and an object hierarchy similar to TodoPriority (afterwards, I want to use case classes). See the diff here (clone the repository)

https://github.com/MikaelMayer/scalajs-spa-tutorial/commit/71a2ec1ca385d6f7ebe7302b20f59957d77c50cb

Then do sbt run and navigate in your browser to localhost:9000

Expected

No error on the command line

Actual

Request path: spatutorial/shared/Api/getTodos
Request path: spatutorial/shared/Api/getMessage
Request path: spatutorial/shared/Api/motd
Sending 4 Todo items
[error] p.c.s.n.PlayDefaultUpstreamHandler - Cannot invoke the action
scala.MatchError: Request(WrappedArray(spatutorial, shared, Api, getMessage),Map
(what -> java.nio.HeapByteBuffer[pos=0 lim=3 cap=3])) (of class autowire.Core$Re
quest)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:253) ~[scala-library-2.11.7.jar:na]
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:251) ~[scala-library-2.11.7.jar:na]
    at controllers.Application$$anonfun$autowireApi$1$$anonfun$apply$1.applyOrElse(Application.scala:32) ~[classes/:na]
    at controllers.Application$$anonfun$autowireApi$1$$anonfun$apply$1.applyOrElse(Application.scala:32) ~[classes/:na]
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) ~[scala-library-2.11.7.jar:na]
    at controllers.Application$$anonfun$autowireApi$1.apply(Application.scala:32) ~[classes/:na]
    at controllers.Application$$anonfun$autowireApi$1.apply(Application.scala:25) ~[classes/:na]
    at play.api.mvc.Action$.invokeBlock(Action.scala:533) ~[play_2.11-2.4.2.jar:2.4.2]
    at play.api.mvc.Action$.invokeBlock(Action.scala:530) ~[play_2.11-2.4.2.jar:2.4.2]
    at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:493) ~[play_2.11-2.4.2.jar:2.4.2][error] application -! @6nd17m8mc - Internal server error, for (POST) [/api/spatutorial/shared/Api/getMessage] ->play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[MatchError: Request(WrappedArray(spatutorial, shared, Api, getMessage),Map(what -> java.nio.HeapByteBuffer[pos=0 lim=3 cap=3])) (of class autowire.Core$Request)]]
    at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:265) ~[play_2.11-2.4.2.jar:2.4.2]
    at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:191) ~[play_2.11-2.4.2.jar:2.4.2]
    at play.api.GlobalSettings$class.onError(GlobalSettings.scala:179) [play_2.11-2.4.2.jar:2.4.2]
    at play.api.DefaultGlobal$.onError(GlobalSettings.scala:212) [play_2.11-2.4.2.jar:2.4.2]
    at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:94) [play_2.11-2.4.2.jar:2.4.2]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:273) [play-netty-server_2.11-2.4.2.jar:2.4.2]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:269) [play-netty-server_2.11-2.4.2.jar:2.4.2]
    at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344) [scala-library-2.11.7.jar:na]
    at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343) [scala-library-2.11.7.jar:na]
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [scala-library-2.11.7.jar:na]Caused by: scala.MatchError: Request(WrappedArray(spatutorial, shared, Api, getMessage),Map(what -> java.nio.HeapByteBuffer[pos=0 lim=3 cap=3])) (of class autowire.Core$Request)
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:253) ~[scala-library-2.11.7.jar:na]
    at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:251) ~[scala-library-2.11.7.jar:na]
    at controllers.Application$$anonfun$autowireApi$1$$anonfun$apply$1.applyOrElse(Application.scala:32) ~[classes/:na]
    at controllers.Application$$anonfun$autowireApi$1$$anonfun$apply$1.applyOrElse(Application.scala:32) ~[classes/:na]
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) ~[scala-library-2.11.7.jar:na]
    at controllers.Application$$anonfun$autowireApi$1.apply(Application.scala:32) ~[classes/:na]
    at controllers.Application$$anonfun$autowireApi$1.apply(Application.scala:25) ~[classes/:na]
    at play.api.mvc.Action$.invokeBlock(Action.scala:533) ~[play_2.11-2.4.2.jar:2.4.2]
    at play.api.mvc.Action$.invokeBlock(Action.scala:530) ~[play_2.11-2.4.2.jar:2.4.2]
    at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:493) ~[play_2.11-2.4.2.jar:2.4.2]CLIENT - [{"logger":"Log","timestamp":1441725398897,"level":"INFO","url":"http://localhost:9000/","message":"This message goes to server as well"}]
MikaelMayer commented 9 years ago

Ok I figured out how to correct this.

I had to do sbt clean every time I make modifications to the shared project.

Thanks for this very nice tutorial.