jaliss / securesocial

A module that provides OAuth, OAuth2 and OpenID authentication for Play Framework applications
http://www.securesocial.ws
Apache License 2.0
1.19k stars 510 forks source link

Not able to get this working: java.lang.NoClassDefFoundError: Could not initialize class securesocial.core.providers.utils.RoutesHelper$ #115

Closed adpande closed 11 years ago

adpande commented 11 years ago

Hi,

I am using play 2.0.4 Java with SS 2.0.7.

I am getting this error when hitting the /login url.

[error] application -

! @6cik8gn4n - Internal server error, for request [GET /login] ->

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[NoClassDefFoundError: Could not initialize class securesocial.core.providers.utils.RoutesHelper$]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.4] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.4] at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2] at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.4] at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.jar:2.0.2] Caused by: java.lang.NoClassDefFoundError: Could not initialize class securesocial.core.providers.utils.RoutesHelper$ at securesocial.core.IdentityProvider.authenticationUrl(IdentityProvider.scala:93) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] at securesocial.views.html.provider$$anonfun$apply$1$$anonfun$apply$2.apply(provider.template.scala:42) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] at securesocial.views.html.provider$$anonfun$apply$1$$anonfun$apply$2.apply(provider.template.scala:41) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] at play.templates.TemplateMagic$.defining(ScalaTemplates.scala:756) ~[templates_2.9.1.jar:2.0.4] at securesocial.views.html.provider$$anonfun$apply$1.apply(provider.template.scala:41) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] at securesocial.views.html.provider$$anonfun$apply$1.apply(provider.template.scala:39) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] [debug] application - Calling deleteExpiredTokens() [debug] application - Calling deleteExpiredTokens() [debug] application - Calling deleteExpiredTokens()

adpande commented 11 years ago

Sorry for posting it here. I am not able to find any forum/group links. I am also getting the following error:

[error] application -

! @6cike0o6p - Internal server error, for request [GET /login] ->

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[ExceptionInInitializerError: null]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.4] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.4] at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2] at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.4] at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.jar:2.0.2] Caused by: java.lang.ExceptionInInitializerError: null at securesocial.core.IdentityProvider.authenticationUrl(IdentityProvider.scala:93) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] at securesocial.views.html.provider$$anonfun$apply$1$$anonfun$apply$2.apply(provider.template.scala:42) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] at securesocial.views.html.provider$$anonfun$apply$1$$anonfun$apply$2.apply(provider.template.scala:41) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] at play.templates.TemplateMagic$.defining(ScalaTemplates.scala:756) ~[templates_2.9.1.jar:2.0.4] at securesocial.views.html.provider$$anonfun$apply$1.apply(provider.template.scala:41) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] at securesocial.views.html.provider$$anonfun$apply$1.apply(provider.template.scala:39) ~[securesocial_2.9.1-2.0.7.jar:2.0.7] Caused by: java.lang.ClassNotFoundException: securesocial.controllers.ReverseRegistration at java.net.URLClassLoader$1.run(URLClassLoader.java:202) ~[na:1.6.0_37] at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_37] at java.net.URLClassLoader.findClass(URLClassLoader.java:190) ~[na:1.6.0_37] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) ~[na:1.6.0_37] at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ~[na:1.6.0_37] at sbt.PlayCommands$$anonfun$61$$anonfun$63$$anon$2$$anonfun$loadClass$1.apply(PlayCommands.scala:563) ~[na:na]

jaliss commented 11 years ago

Are you using a custom assets controller?

adpande commented 11 years ago

Nope. I am not using it. I am new to play.

jaliss commented 11 years ago

can you share your routes file?

On Mon, Dec 10, 2012 at 11:45 AM, Abhishek Pande notifications@github.comwrote:

Nope. I am not using it. I am new to play.

— Reply to this email directly or view it on GitHubhttps://github.com/jaliss/securesocial/issues/115#issuecomment-11214000.

adpande commented 11 years ago

Routes

This file defines all application routes (Higher priority routes first)

~~~~

Home page

GET / controllers.Application.index() GET /diffs/:page controllers.DiffController.showPage(page:String)

Login page

GET /login securesocial.controllers.LoginPage.login GET /logout securesocial.controllers.LoginPage.logout

User Registration and password handling (only needed if you are using UsernamePasswordProvider)

GET /signup securesocial.controllers.Registration.startSignUp

POST /signup securesocial.controllers.Registration.handleStartSignUp

GET /signup/:token securesocial.controllers.Registration.signUp(token)

POST /signup/:token securesocial.controllers.Registration.handleSignUp(token)

GET /reset securesocial.controllers.Registration.startResetPassword

POST /reset securesocial.controllers.Registration.handleStartResetPassword

GET /reset/:token securesocial.controllers.Registration.resetPassword(token)

POST /reset/:token securesocial.controllers.Registration.handleResetPassword(token)

GET /password securesocial.controllers.PasswordChange.page

POST /password securesocial.controllers.PasswordChange.handlePasswordChange

Providers entry points

GET /authenticate/:provider securesocial.controllers.ProviderController.authenticate(provider) POST /authenticate/:provider securesocial.controllers.ProviderController.authenticateByPost(provider)

Map static resources from the /public folder to the /assets URL path

GET /assets/*file controllers.Assets.at(path="/public", file)

jaliss commented 11 years ago

You commented out the routes for the UsernamePasswordProvider but it looks like you are including it in your play.plugins file. That's why it's failing.

adpande commented 11 years ago

Nope. I do not have UsernamePasswordProvider in play.plugins.

Sent on my BlackBerry® from Vodafone

-----Original Message----- From: Jorge notifications@github.com Date: Mon, 10 Dec 2012 18:00:28 To: jaliss/securesocialsecuresocial@noreply.github.com Reply-To: jaliss/securesocial reply@reply.github.com Cc: Abhishek Pandeadpande@gmail.com Subject: Re: [securesocial] Not able to get this working: java.lang.NoClassDefFoundError: Could not initialize class securesocial.core.providers.utils.RoutesHelper$ (#115)

You commented out the routes for the UsernamePasswordProvider but it looks like you are including it in your play.plugins file. That's why it's failing.


Reply to this email directly or view it on GitHub: https://github.com/jaliss/securesocial/issues/115#issuecomment-11227995

relrod commented 11 years ago

I recently ran into this as well. The GET ones from the block that says "User Registration and password handling (only needed if you are using UsernamePasswordProvider)" must be uncommented, or that exception will get thrown, even if you aren't using UsernamePasswordProvider. This took me a good amount of time to figure out. :(

adpande commented 11 years ago

Got it working! Thanks @CodeBlock

This is a bug then.

jaliss commented 11 years ago

Will check this out. Thanks @CodeBlock for the work around.

jaliss commented 11 years ago

I updated the docs and made those routes required. They won't be used but RoutesHelper needs them there.

derekdon commented 11 years ago

I'm trying out the scala sample and getting the same kind of errors.

[securesocial] anonymous user trying to access : '/' ... Internal server error, for request [GET /login] -> play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[NoClassDefFoundError: Could not initialize class securesocial.core.providers.utils.RoutesHelper$]] ... Internal server error, for request [GET /signup] ->

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[NoClassDefFoundError: Could not initialize class securesocial.core.providers.utils.RoutesHelper$]]

Routes file looks like:

Home page

GET / controllers.Application.index GET /only-twitter controllers.Application.onlyTwitter

Map static resources from the /public folder to the /assets URL path

GET /assets/*file controllers.Assets.at(path="/public", file)

Login page

GET /login securesocial.controllers.LoginPage.login GET /logout securesocial.controllers.LoginPage.logout

User Registration and password handling

GET /signup securesocial.controllers.Registration.startSignUp POST /signup securesocial.controllers.Registration.handleStartSignUp GET /signup/:token securesocial.controllers.Registration.signUp(token) POST /signup/:token securesocial.controllers.Registration.handleSignUp(token) GET /reset securesocial.controllers.Registration.startResetPassword POST /reset securesocial.controllers.Registration.handleStartResetPassword GET /reset/:token securesocial.controllers.Registration.resetPassword(token) POST /reset/:token securesocial.controllers.Registration.handleResetPassword(token) GET /password securesocial.controllers.PasswordChange.page POST /password securesocial.controllers.PasswordChange.handlePasswordChange

Providers entry points

GET /authenticate/:provider securesocial.controllers.ProviderController.authenticate(provider) POST /authenticate/:provider securesocial.controllers.ProviderController.authenticateByPost(provider) GET /not-authorized securesocial.controllers.ProviderController.notAuthorized

derekdon commented 11 years ago

assetsController=controllers.ReverseMyCustomAssetsController

... in securesocial.conf isn't commented out by default, easy to miss. Commenting it out fixes my issue.

jaliss commented 11 years ago

@derekdon what version are you using? just checked and that property is not there in the securesocial.conf files for master and 2.0.8 in both Java and Scala samples.

derekdon commented 11 years ago

@jaliss Yeah I can see that now, I must of copied the basis contents from the http://securesocial.ws/guide/configuration.html and not taken it directly from the scala sample.

Seems to be okay now, but I am having another problem... when I allow the app access via google auth it then drops me back to the login page... console shows the following error.

[error] application - Unable to log user in. An exception was thrown securesocial.core.AuthenticationException: null at securesocial.core.OAuth2Provider.doAuth(OAuth2Provider.scala:114) ~[securesocial_2.9.1-2.0.8.jar:2.0.8] at securesocial.core.IdentityProvider.authenticate(IdentityProvider.scala:73) ~[securesocial_2.9.1-2.0.8.jar:2.0.8] at securesocial.controllers.ProviderController$$anonfun$handleAuth$1.apply(ProviderController.scala:85) [securesocial_2.9.1-2.0.8.jar:2.0.8] at securesocial.controllers.ProviderController$$anonfun$handleAuth$1.apply(ProviderController.scala:81) [securesocial_2.9.1-2.0.8.jar:2.0.8] at play.api.mvc.Action$$anon$1.apply(Action.scala:170) [play_2.9.1-2.0.4.jar:2.0.4] at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) [play_2.9.1-2.0.4.jar:2.0.4]

Going to dig into this later, but for now do you have any ideas what's wrong?

derekdon commented 11 years ago

Also seeing this when I start up the app and try to access /

Play server process ID is 4414 [info] application - [securesocial] loaded templates plugin: securesocial.controllers.DefaultTemplatesPlugin [info] play - Starting application default Akka system. [info] application - [securesocial] loaded user service: class service.InMemoryUserService [info] application - [securesocial] loaded password hasher bcrypt [info] application - Application has started [debug] application - [securesocial] calling deleteExpiredTokens() 2013-01-11 09:13:19.983 INFO com.couchbase.client.CouchbaseConnection: Added {QA sa=/127.0.0.1:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue 2013-01-11 09:13:19.988 INFO com.couchbase.client.CouchbaseConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@19f9d2 2013-01-11 09:13:19.988 INFO com.couchbase.client.CouchbaseClient: viewmode set to development mode 2013-01-11 09:13:20.058 INFO net.spy.memcached.auth.AuthThread: Authenticated to localhost.localdomain/127.0.0.1:11210 2013-01-11 09:13:20.068 INFO com.couchbase.client.ViewConnection: Added localhost.localdomain/127.0.0.1:8092 to connect queue [info] application - [securesocial] loaded identity provider: twitter [info] application - [securesocial] loaded identity provider: google [info] application - [securesocial] loaded identity provider: userpass [info] play - Application started (Prod) [info] play - Listening for HTTP on port 9000... [error] application -

! @6d1hj5png - Internal server error, for request [GET /] ->

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1-2.0.4.jar:2.0.4] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1-2.0.4.jar:2.0.4] at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor-2.0.2.jar:2.0.2] at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1-2.0.4.jar:2.0.4] at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor-2.0.2.jar:2.0.2] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor-2.0.2.jar:2.0.2] Caused by: java.lang.IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added at org.jboss.netty.handler.codec.http.CookieEncoder.encodeServerSide(CookieEncoder.java:101) ~[netty-3.5.5.Final.jar:na] at org.jboss.netty.handler.codec.http.CookieEncoder.encode(CookieEncoder.java:91) ~[netty-3.5.5.Final.jar:na] at play.api.mvc.Cookies$.encode(Http.scala:574) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.Cookies$.merge(Http.scala:598) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.PlainResult$class.withCookies(Results.scala:84) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.SimpleResult.withCookies(Results.scala:192) ~[play_2.9.1-2.0.4.jar:2.0.4]

jaliss commented 11 years ago

@derekdon do you see the error if you run the app in dev mode?

derekdon commented 11 years ago

@jaliss If I run it on my VPS via sbt run (dev mode?), I still see the following when I access /

Execution exception

[IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added]

... accessing the /login page works fine, as does clicking google to authenticate, allowing access, but again I am throw back to the login page with the following:

[debug] application - [securesocial] authorizationUrl = https://accounts.google.com/o/oauth2/auth [debug] application - [securesocial] redirecting to: [https://accounts.google.com/o/oauth2/auth?scope=..[removed for github post] [debug] application - [securesocial] user = None [error] application - Unable to log user in. An exception was thrown securesocial.core.AuthenticationException: null at securesocial.core.OAuth2Provider.doAuth(OAuth2Provider.scala:114) ~[securesocial_2.9.1-2.0.8.jar:2.0.8] at securesocial.core.IdentityProvider.authenticate(IdentityProvider.scala:73) ~[securesocial_2.9.1-2.0.8.jar:2.0.8] at securesocial.controllers.ProviderController$$anonfun$handleAuth$1.apply(ProviderController.scala:85) [securesocial_2.9.1-2.0.8.jar:2.0.8] at securesocial.controllers.ProviderController$$anonfun$handleAuth$1.apply(ProviderController.scala:81) [securesocial_2.9.1-2.0.8.jar:2.0.8] at play.api.mvc.Action$$anon$1.apply(Action.scala:170) [play_2.9.1-2.0.4.jar:2.0.4] at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) [play_2.9.1-2.0.4.jar:2.0.4]

derekdon commented 11 years ago

Using: "securesocial" % "securesocial_2.9.1" % "2.0.8", ... resolvers += Resolver.url("SecureSocial Repository", url("http://securesocial.ws/repository/releases/"))(Resolver.ivyStylePatterns),

derekdon commented 11 years ago

@jaliss Might be something to do with the InMemoryUserService in production, but it doesn't seem to be working in dev mode either.

jaliss commented 11 years ago

@derekdon I don't think that's releted. It's complaining about encoding 2 cookies. Can you try running from the play console? the error says you are running in prod mode

derekdon commented 11 years ago

@jaliss Sorry about this, maybe leave it with my and I can try to figure it out... Results below on local machine, same issue.

D:\dev\code\test\mm\mm.play>play [info] Loading project definition from D:\dev\code\test\mm\mm.play\project [info] Set current project to mm.play (in build file:/D:/dev/code/test/mm/mm.play/) | | | | | ' | |/ ' | || || | **/||**| () || |__/

play! 2.0.3, http://www.playframework.org

Type "help play" or "license" for more information. Type "exit" or use Ctrl+D to leave this console.

[mm.play] $ run

[info] Updating {file:/D:/dev/code/test/mm/mm.play/}mm.play... [info] Done updating. --- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on port 9000...

(Server started, use Ctrl+D to stop and go back to the console...)

[info] Compiling 9 Scala sources and 1 Java source to D:\dev\code\test\mm\mm.play\target\scala-2.9.1\classes... [info] application - [securesocial] loaded templates plugin: securesocial.controllers.DefaultTemplatesPlugin [info] play - Starting application default Akka system. [info] application - [securesocial] loaded user service: class service.InMemoryUserService [info] application - [securesocial] loaded password hasher bcrypt [info] application - [securesocial] loaded identity provider: twitter [info] application - Application has started [debug] application - [securesocial] calling deleteExpiredTokens() 2013-01-11 14:30:08.778 INFO com.couchbase.client.CouchbaseConnection: Added {QA sa=/127.0.0.1:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue 2013-01-11 14:30:08.792 INFO com.couchbase.client.CouchbaseClient: viewmode set to development mode 2013-01-11 14:30:08.792 INFO com.couchbase.client.CouchbaseConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@1bda30a 2013-01-11 14:30:08.912 INFO net.spy.memcached.auth.AuthThread: Authenticated to 127.0.0.1/127.0.0.1:11210 2013-01-11 14:30:08.916 INFO com.couchbase.client.ViewConnection: Added 127.0.0.1/127.0.0.1:8092 to connect queue [info] application - [securesocial] loaded identity provider: google [info] application - [securesocial] loaded identity provider: userpass [info] play - Application started (Dev) [debug] application - [securesocial] anonymous user trying to access : '/' [debug] application - [securesocial] assets controller = controllers.ReverseAssets [error] application -

! @6d1j8i4bj - Internal server error, for request [GET /] ->

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1-2.0.4.jar:2.0.4] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1-2.0.4.jar:2.0.4] at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2] at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1-2.0.4.jar:2.0.4] at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.jar:2.0.2] Caused by: java.lang.IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added at org.jboss.netty.handler.codec.http.CookieEncoder.encodeServerSide(CookieEncoder.java:101) ~[netty-3.5.5.Final.jar:na] at org.jboss.netty.handler.codec.http.CookieEncoder.encode(CookieEncoder.java:91) ~[netty-3.5.5.Final.jar:na] at play.api.mvc.Cookies$.encode(Http.scala:574) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.Cookies$.merge(Http.scala:598) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.PlainResult$class.withCookies(Results.scala:84) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.SimpleResult.withCookies(Results.scala:192) ~[play_2.9.1-2.0.4.jar:2.0.4]

jaliss commented 11 years ago

you are using play 2.0.3 .. can you try 2.0.4?

derekdon commented 11 years ago

@jaliss Sure, give me a few minutes... Thanks for your help

derekdon commented 11 years ago

@jaliss Not sure why I'm seeing "Update the Play sbt-plugin version to 2.0.3 (usually in project/plugins.sbt)" when it is now set to 2.0.4? You can see the jars are play_2.9.1-2.0.4.jar

Anyway the output is the same...

D:\dev\code\test\mm\mm.play>play [info] Loading project definition from D:\dev\code\test\mm\mm.play\project

This project uses Play 2.0.4! Update the Play sbt-plugin version to 2.0.3 (usually in project/plugins.sbt)

[info] Set current project to mm.play (in build file:/D:/dev/code/test/mm/mm.play/) | | | | | ' | |/ ' | || || | **/||**| () || |__/

play! 2.0.4, http://www.playframework.org

Type "help play" or "license" for more information. Type "exit" or use Ctrl+D to leave this console.

[mm.play] $ run

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on port 9000...

(Server started, use Ctrl+D to stop and go back to the console...)

[info] Compiling 9 Scala sources and 3 Java sources to D:\dev\code\test\mm\mm.play\target\scala-2.9.1\classes... [info] application - [securesocial] loaded templates plugin: securesocial.controllers.DefaultTemplatesPlugin [info] play - Starting application default Akka system. [info] application - [securesocial] loaded user service: class service.InMemoryUserService [info] application - [securesocial] loaded password hasher bcrypt [info] application - [securesocial] loaded identity provider: twitter [info] application - Application has started [debug] application - [securesocial] calling deleteExpiredTokens() 2013-01-11 15:15:51.622 INFO com.couchbase.client.CouchbaseConnection: Added {QA sa=/127.0.0.1:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue 2013-01-11 15:15:51.642 INFO com.couchbase.client.CouchbaseConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@116639 2013-01-11 15:15:51.643 INFO com.couchbase.client.CouchbaseClient: viewmode set to development mode 2013-01-11 15:15:51.729 INFO net.spy.memcached.auth.AuthThread: Authenticated to 127.0.0.1/127.0.0.1:11210 2013-01-11 15:15:51.738 INFO com.couchbase.client.ViewConnection: Added 127.0.0.1/127.0.0.1:8092 to connect queue [info] application - [securesocial] loaded identity provider: google [info] application - [securesocial] loaded identity provider: userpass [info] play - Application started (Dev) [debug] application - [securesocial] anonymous user trying to access : '/' [debug] application - [securesocial] assets controller = controllers.ReverseAssets [error] application -

! @6d1jejk6e - Internal server error, for request [GET /] ->

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1-2.0.4.jar:2.0.4] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1-2.0.4.jar:2.0.4] at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2] at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1-2.0.4.jar:2.0.4] at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.jar:2.0.2] Caused by: java.lang.IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added at org.jboss.netty.handler.codec.http.CookieEncoder.encodeServerSide(CookieEncoder.java:101) ~[netty-3.5.5.Final.jar:na] at org.jboss.netty.handler.codec.http.CookieEncoder.encode(CookieEncoder.java:91) ~[netty-3.5.5.Final.jar:na] at play.api.mvc.Cookies$.encode(Http.scala:574) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.Cookies$.merge(Http.scala:598) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.PlainResult$class.withCookies(Results.scala:84) ~[play_2.9.1-2.0.4.jar:2.0.4] at play.api.mvc.SimpleResult.withCookies(Results.scala:192) ~[play_2.9.1-2.0.4.jar:2.0.4]

derekdon commented 11 years ago

Just switched from 2.0.8 to using;

"securesocial" % "securesocial_2.9.1" % "master", ... and resolvers += Resolver.url("SecureSocial Repository", url("http://securesocial.ws/repository/snapshots/"))(Resolver.ivyStylePatterns),

but it's still an issue unfortunately.

[IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added]

derekdon commented 11 years ago

@jaliss Right I just updated the VPS to use Play 2.0.4 and tried it again on the server in dev mode, same results I'm afraid. What the hell am I doing wrong? Driving me nuts.

[mm.play] $ root@buildserver1:/usr/share/jenkins/jobs/mm.play/workspace# play [info] Loading project definition from /usr/share/jenkins/jobs/mm.play/workspace/project [info] Set current project to mm.play (in build file:/usr/share/jenkins/jobs/mm.play/workspace/) | | | | | ' | |/ ' | || || | **/||**| () || |__/

play! 2.0.4, http://www.playframework.org

Type "help play" or "license" for more information. Type "exit" or use Ctrl+D to leave this console.

[mm.play] $ run

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on port 9000...

(Server started, use Ctrl+D to stop and go back to the console...)

[info] application - [securesocial] loaded templates plugin: securesocial.controllers.DefaultTemplatesPlugin [info] play - Starting application default Akka system. [info] application - [securesocial] loaded user service: class service.InMemoryUserService [info] application - [securesocial] loaded password hasher bcrypt [info] application - [securesocial] loaded identity provider: twitter [info] application - Application has started [debug] application - [securesocial] calling deleteExpiredTokens() 2013-01-11 15:53:19.468 INFO com.couchbase.client.CouchbaseConnection: Added {QA sa=/127.0.0.1:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue 2013-01-11 15:53:19.473 INFO com.couchbase.client.CouchbaseConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@65724d 2013-01-11 15:53:19.474 INFO com.couchbase.client.CouchbaseClient: viewmode set to development mode 2013-01-11 15:53:19.785 INFO net.spy.memcached.auth.AuthThread: Authenticated to localhost.localdomain/127.0.0.1:11210 2013-01-11 15:53:19.812 INFO com.couchbase.client.ViewConnection: Added localhost.localdomain/127.0.0.1:8092 to connect queue [info] application - [securesocial] loaded identity provider: google [info] application - [securesocial] loaded identity provider: userpass [info] play - Application started (Dev) [debug] application - [securesocial] anonymous user trying to access : '/' [debug] application - [securesocial] assets controller = controllers.ReverseAssets [error] application -

! @6d1jjici7 - Internal server error, for request [GET /] ->

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.4] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.4] at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2] at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.4] at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.jar:2.0.2] Caused by: java.lang.IllegalStateException: encode() can encode only one cookie on server mode: 2 cookies added at org.jboss.netty.handler.codec.http.CookieEncoder.encodeServerSide(CookieEncoder.java:101) ~[netty-3.5.5.Final.jar:na] at org.jboss.netty.handler.codec.http.CookieEncoder.encode(CookieEncoder.java:91) ~[netty-3.5.5.Final.jar:na] at play.api.mvc.Cookies$.encode(Http.scala:574) ~[play_2.9.1.jar:2.0.4] at play.api.mvc.Cookies$.merge(Http.scala:598) ~[play_2.9.1.jar:2.0.4] at play.api.mvc.PlainResult$class.withCookies(Results.scala:84) ~[play_2.9.1.jar:2.0.4] at play.api.mvc.SimpleResult.withCookies(Results.scala:192) ~[play_2.9.1.jar:2.0.4] [info] play - Shutdown application default Akka system. [debug] application - [securesocial] calling deleteExpiredTokens() [info] application - [securesocial] unloaded password hasher bcrypt [info] application - [securesocial] unloaded identity provider: twitter [info] application - Application shutdown... 2013-01-11 15:53:23.215 INFO com.couchbase.client.CouchbaseConnection: Shut down Couchbase client 2013-01-11 15:53:23.223 WARN com.couchbase.client.ViewConnection: Shutting down with ops waiting to be written 2013-01-11 15:53:23.224 INFO com.couchbase.client.ViewNode: [info] application - [securesocial] unloaded identity provider: google Couchbase I/O reactor terminated [info] application - [securesocial] unloaded identity provider: userpass

derekdon commented 11 years ago

@jaliss Interesting, I downloaded the scala demo as is (didn't change a thing), and ran it locally using $play run, and accessing http://localhost:9000 redirects me to /login as expected without error! Cool! Right just need to figure out the difference. Thanks.

C:\Users\derekdon\Downloads\securesocial-master\samples\scala\demo>play [info] Loading project definition from C:\Users\derekdon\Downloads\securesocial-master\samples\scala\demo\project [info] Set current project to ssdemo-scala (in build file:/C:/Users/derekdon/Downloads/securesocial-master/samples/scala/demo/) | | | | | ' | |/ ' | || || | **/||**| () || |__/

play! 2.0.4, http://www.playframework.org

Type "help play" or "license" for more information. Type "exit" or use Ctrl+D to leave this console.

[ssdemo-scala] $ run

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on port 9000...

(Server started, use Ctrl+D to stop and go back to the console...)

[info] application - [securesocial] loaded templates plugin: securesocial.controllers.DefaultTemplatesPlugin [info] play - Starting application default Akka system. [info] application - [securesocial] loaded user service: class service.InMemoryUserService [info] application - [securesocial] loaded password hasher bcrypt [info] application - [securesocial] loaded identity provider: twitter [info] application - [securesocial] loaded identity provider: facebook [info] application - [securesocial] loaded identity provider: google [info] application - [securesocial] loaded identity provider: linkedin [info] application - [securesocial] loaded identity provider: userpass [info] application - [securesocial] loaded identity provider: github [info] play - Application started (Dev) [debug] application - [securesocial] calling deleteExpiredTokens() [debug] application - [securesocial] anonymous user trying to access : '/' [debug] application - [securesocial] assets controller = controllers.ReverseAssets

derekdon commented 11 years ago

@jaliss Okay I have finally found want is causing this in my case... Not sure why, but if I remove couchbase from my appDependencies it works.

val appDependencies = Seq( "couchbase" % "couchbase-client" % "1.1-dp3",

Even with any couchbase datasource implementation removed, it still wouldn't work until I removed this dependencies in my Build.scala file. Strange... Any idea why that causes it?

Thanks for your help, great to be getting to the bottom of this. Securesocial now looks like a really nice play module that it's working... Just need to figure out how to keep couchbase and securesocial happy together.

jaliss commented 11 years ago

@derekdon weird, good to know you found the problem. did you update your plugins.sbt file to use 2.0.4 instead of 2.0.3?

derekdon commented 11 years ago

@jaliss Yeah I updated the plugins.sbt to 2.0.4. It's strange as both work fine independently in the project, I'm using couchbase in this and other projects without issue. But when both couchbase and securesocial dependencies are defined these errors occur. Reading the error it would seem that perhaps both are adding a cookie of some sort and that only one is allowed... Might try it with the play-oauth-client module and see if that works together with couchbase. It really annoying as I really wanted to use securesocial. I'll keep investigating, but if you want to see it for yourself just add a couchbase dependency to the sample project and that should do it. Cheers.

derekdon commented 11 years ago

@jaliss Am I right in thinking that line 136 of SecureSocial.scala is adding to an existing cookie?

Redirect(RoutesHelper.login()).flashing("error" -> Messages("securesocial.loginRequired")).withSession( session + (SecureSocial.OriginalUrlKey -> request.uri) )

jaliss commented 11 years ago

yes. That line updates the Play session cookie.

buggtb commented 11 years ago

I'm getting the same error, but i don't have a couchbase dependency, I need to get to the bottom of it though because I've already had some Securesocial and JClouds classpath issues, so I suspect sadly its related.

buggtb commented 11 years ago

Looks like something is bringing in a newer version of Netty which has a new feature: if (cookies.size() > 1) { throw new IllegalStateException( "encode() can encode only one cookie on server mode: " + cookies.size() + " cookies added"); }

But the cookie list has a PLAY_FLASH cookie with a thank you comment, and also there is an additional PLAY_SESSION cookie now.

I guess its not securesocial's fault, but i'm not sure how i can go about fixing it, SBT doesn't seem to be able to force older versions of transative dependencies

ripplect002 commented 11 years ago

I am using the java sample provided with securesocial,play 2.0.4, sbt 0.11.3. My target is to edit the custom login page provided by securesocial and as such I have created a new plugin and registered it in play.plugins as securesocial.controllers.Securesviewsplugin. I am using securesocial from https://github.com/dr3s/securesocial As instructed there I have also copied the contents of module-core into my project at project/modules/securesocial. At run time I get the exception that - imported `TemplatesPlugin' is permanently hidden by definition of trait TemplatesPlugin in package controllers How do I clear it