[securesocial play-master-2.2.x][play 2.3.6] Cast Exception BoxedUnit to Authenticator

148 views
Skip to first unread message

Markus Wuersch

unread,
Nov 27, 2014, 9:03:36 AM11/27/14
to secure...@googlegroups.com
Hi,

I am noticing that after I have not logged in for a while I am getting the below cast exception (scala.runtime.BoxedUnit cannot be cast to securesocial.core.authenticator.Authenticator). I am guessing it has something to do with expired tokens since it only happens after a while of inactivity for a user. 
I have seen a similar post but, unfortunately, it didn't help since it was about a custom implementation of AuthenticatorStore. I am using the out-of-the-box Authenticator.

Any pointers to this? 

Thanks,
Markus



2014-11-27 13:52:25,129 - [ERROR] - from play in play-akka.actor.default-dispatcher-8 Cannot invoke the action, eventually got an error: java.lang.ClassCastException: scala.runtime.BoxedUnit cannot be cast to securesocial.core.authenticator.Authenticator2014-11-27 13:52:25,130 - [ERROR] - from application in play-akka.actor.default-dispatcher-8 ! @6kb8a3adp - Internal server error, for (GET) [/v1/children?timestamp=1417096345235] ->play.api.Application$$anon$1: Execution exception[[ClassCastException: scala.runtime.BoxedUnit cannot be cast to securesocial.core.authenticator.Authenticator]] at play.api.Application$class.handleError(Application.scala:296) ~[com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at play.api.DefaultApplication.handleError(Application.scala:402) [com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at scala.Option.map(Option.scala:145) [org.scala-lang.scala-library-2.11.1.jar:na] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:320) [com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:316) [com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [org.scala-lang.scala-library-2.11.1.jar:na] at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:46) [com.typesafe.play.play-iteratees_2.11-2.3.6.jar:2.3.6] at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.impl.Promise$DefaultPromise.link(Promise.scala:304) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.impl.Promise$DefaultPromise.linkRootOf(Promise.scala:289) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:249) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) [org.scala-lang.scala-library-2.11.1.jar:na] at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:40) [com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:41) [com.typesafe.akka.akka-actor_2.11-2.3.4.jar:na] at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) [com.typesafe.akka.akka-actor_2.11-2.3.4.jar:na] at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [org.scala-lang.scala-library-2.11.1.jar:na] at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [org.scala-lang.scala-library-2.11.1.jar:na]Caused by: java.lang.ClassCastException: scala.runtime.BoxedUnit cannot be cast to securesocial.core.authenticator.Authenticator at securesocial.core.java.Secured$1$2.apply(Secured.java:86) ~[ws.securesocial.securesocial_2.11-master-SNAPSHOT.jar:master-SNAPSHOT] at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.scala:101) ~[com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at play.core.j.FPromiseHelper$$anonfun$flatMap$1.apply(FPromiseHelper.scala:101) ~[com.typesafe.play.play_2.11-2.3.6.jar:2.3.6] at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251) [org.scala-lang.scala-library-2.11.1.jar:na] ... 9 common frames omitted

Markus Wuersch

unread,
Nov 27, 2014, 9:05:14 AM11/27/14
to secure...@googlegroups.com
here is a better formatted version of the exception trace:

Fernando Moyses

unread,
Dec 4, 2014, 3:44:41 PM12/4/14
to secure...@googlegroups.com
Hi!
We're facing the same problem with 3.0-M1-play-2.2.x
With some debug we think the problem is with the "Authenticator.scala".
There's a method:

def discarding(javaContext: play.mvc.Http.Context): Future[Unit]

This returns a Unit for Java Actions when there's a timeout.

In the "Secured.java" source there's:

return F.Promise.wrap(authenticatorOption.get().discarding(ctx)).flatMap(
                                       
new F.Function<Authenticator, F.Promise<Result>>() {
                                           
@Override
                                           
public F.Promise<Result> apply(Authenticator authenticator) throws Throwable {
                                               
return responses.notAuthenticatedResult(ctx);
                                           
}
                                       
}
                               
);

The flatMap is expecting an Authenticator for the discarding method, but it's actually receiving the Unit as expected by Authenticator.discarding signature.
It seems to be a bug.

Maybe jaliss could give us a hand?

Fernando Moyses

unread,
Dec 4, 2014, 3:47:19 PM12/4/14
to secure...@googlegroups.com
Ops!
Looks like someone already did it.

Markus Wuersch

unread,
Dec 4, 2014, 3:53:36 PM12/4/14
to Fernando Moyses, secure...@googlegroups.com
Yes, Jorge actually contacted me saying that it will be fixed with the next master update (sorry for not updating this thread!). I suppose until then we can build it ourselves with this pull request merged. 

Cheers,
Markus


sent from mobile

Jorge Aliss

unread,
Dec 10, 2014, 3:02:51 PM12/10/14
to secure...@googlegroups.com, fmo...@gmail.com
Guys,

I just updated master-SNAPSHOT with a fix.
Let me know if it works for you.
Thanks,

Jorge

Fernando Moyses

unread,
Dec 10, 2014, 3:18:34 PM12/10/14
to Jorge Aliss, secure...@googlegroups.com
Hi Jorge!

We're currently using master-play-2.2.x. Will this branch be updated?

Thanks!

Jorge Aliss

unread,
Dec 10, 2014, 6:39:47 PM12/10/14
to secure...@googlegroups.com, jal...@gmail.com
If many people need it I can port some changes to the play-2.2.x branch.  My plan is to continue working on 2.3.
Reply all
Reply to author
Forward
0 new messages