joscha / play-authenticate

An authentication plugin for Play Framework 2.x (Java)
http://joscha.github.com/play-authenticate/
Other
807 stars 367 forks source link

Exception with LinkedIn provider and play2-memcached plugin #291

Open EvanDooner opened 8 years ago

EvanDooner commented 8 years ago

We've switched our application cache from the default EHCache implementation to a memcached-based one, using the play2-memcached plugin.

When trying to link a LinkedIn identity to an existing account, we're encountering the following exception:

play.api.Application$$anon$1: Execution exception[[NotSerializableException: com.feth.play.module.pa.user.EmploymentsIdentity$EmploymentInfo]]
    at play.api.Application$class.handleError(Application.scala:293) ~[play_2.10.jar:2.2.5]
    at play.api.DefaultApplication.handleError(Application.scala:399) [play_2.10.jar:2.2.5]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:264) [play_2.10.jar:2.2.5]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:264) [play_2.10.jar:2.2.5]
    at scala.Option.map(Option.scala:145) [scala-library.jar:na]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:264) [play_2.10.jar:2.2.5]
Caused by: java.io.NotSerializableException: com.feth.play.module.pa.user.EmploymentsIdentity$EmploymentInfo
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183) ~[na:1.7.0_91]
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) ~[na:1.7.0_91]
    at java.util.ArrayList.writeObject(ArrayList.java:742) ~[na:1.7.0_91]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_91]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_91]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_91]

I believe this is caused by the serialization engine used by the play2-memached plugin. The plugin uses Java serialization to serialize objects, and thus relies on the Serializable interface.

I have forked Play Authenticate, and intend to change com.feth.play.module.pa.user.EmploymentsIdentity.EmploymentInfo to implement the Serializable interface.

I'm raising this issue to make you aware of it, and ask if there would be interest in pulling this change back into master?

I believe this is related to #276 , as that user is also using the play2-memcached plugin to add memcached support.

Affected Play version: 2.2.5

joscha commented 8 years ago

I am happy to merge any PR related to this issue coming along ;)

joscha commented 8 years ago

Pulled all the changes up. Will release new versions later. Snapshots should appear automatically, so if you could try one, that'd be great.

EvanDooner commented 8 years ago

About to try the 2.2.x snapshot now. I'll let you know how I get on.

EvanDooner commented 8 years ago

I'm not sure how to find the updated snapshots. I've downloaded the snapshot at http://joscha.github.com/play-authenticate/repo/snapshots/com.feth/play-authenticate_2.10/0.5.3-SNAPSHOT/jars/play-authenticate_2.10.jar, but it doesn't seem to have the updated code. Can you advise?

joscha commented 8 years ago

They are here: http://joscha.github.io/play-authenticate/repo/ Release 0.7.1, 0.6.9, 0.5.4 (thats the one you want) and 0.3.6.

Edit: 0.6.x and higher are available through maven central.

csabaujvari commented 8 years ago

After saw the #291 issue and updating play authenticate dependency to 0.7.1, we still have the same exception when we try to login with LinkedIn provider.

[error] - memcached.plugin - An error has occured while getting the value from memcached. ct=Any
java.util.concurrent.ExecutionException: java.io.InvalidClassException: com.feth.play.module.pa.providers.oauth1.OAuth1AuthProvider$SerializableRequestToken; no valid constructor

Affected Play version: 2.4.4

joscha commented 8 years ago

Can you write a test that shows this problem and/or provide a fix? On 18 Dec 2015 7:30 am, "Csabi" notifications@github.com wrote:

After saw the #291 https://github.com/joscha/play-authenticate/issues/291 issue and updating play authenticate dependency to 0.7.1, we still have an exception when we try to login with LinkedIn provider.

[error] - memcached.plugin - An error has occured while getting the value from memcached. ct=Anyjava.util.concurrent.ExecutionException: java.io.InvalidClassException: com.feth.play.module.pa.providers.oauth1.OAuth1AuthProvider$SerializableRequestToken; no valid constructor

Affected Play version: 2.4.4

— Reply to this email directly or view it on GitHub https://github.com/joscha/play-authenticate/issues/291#issuecomment-165574144 .

csabaujvari commented 8 years ago

I only found the line where it throws the exception:

PlayAuthenticate.java:295

I will try to figure it out.