[Play 2.3 Java] Reverse routing type mismatch with "Nothing" ...

34 views
Skip to first unread message

Aurélien Panhaleux

unread,
Jun 29, 2016, 8:45:57 AM6/29/16
to play-framework
Hi,

Just performed a huge front end refactoring on my play 2.3 app, in this transition, I got some strange errors in reverse routing.

Take this action : 
public static Result catalogByCategory(String category) {
 
// ...
}

Mapped on that route : 
GET /catalog/category/:c controllers.Catalog.catalogByCategory(c: String)

When I call the reverse routing in any view, for example like this : 
@routes.Catalog.catalogByCategory(OperationCategory.DIVERS.toString)

I get one error highlighting saying this :
Type mismatch, expected Nothing, actual String.

My code doesn't compile since this, and just after the application launches I get this pretty error (who's not coming from any top-level application file) : 
 
 play.api.Application$$anon$1: Execution exception[[NullPointerException: null]]
 at play
.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.10.jar:2.3.10]
 at play
.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.10.jar:2.3.10]
 at play
.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205) [play_2.11-2.3.10.jar:2.3.10]
 at play
.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202) [play_2.11-2.3.10.jar:2.3.10]
 at scala
.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [scala-library-2.11.6.jar:na]
Caused by: java.lang.NullPointerException: null
 at scala
.Predef$.Integer2int(Predef.scala:357) ~[scala-library-2.11.6.jar:na]
 at play
.api.mvc.PathBindable$$anonfun$bindableJavaInteger$4.apply(Binders.scala:554) ~[play_2.11-2.3.10.jar:2.3.10]
 at play
.api.mvc.PathBindable$$anonfun$bindableJavaInteger$4.apply(Binders.scala:554) ~[play_2.11-2.3.10.jar:2.3.10]
 at play
.api.mvc.PathBindable$$anon$2.unbind(Binders.scala:185) ~[play_2.11-2.3.10.jar:2.3.10]
 at controllers
.ReverseClients.history(routes_reverseRouting.scala:3818) ~[classes/:na]

I don't know whether to take the bull by the horns or the tail, is it a bug due to Play framework directly ?

Thanks for your time,

gustavo....@trt14.jus.br

unread,
Jun 29, 2016, 9:13:00 AM6/29/16
to play-framework
Hi

try to rename String category (param) to String c.

Aurélien Panhaleux

unread,
Jun 29, 2016, 10:37:48 AM6/29/16
to play-framework
Well I finally found the problem, just had to read the last line of the stack trace...
I was calling a route with a null parameter over an Integer, and scala does not accept null values for Integers.
Wish I had a clearer error message.

Thanks anyway :) 
Reply all
Reply to author
Forward
0 new messages