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

Sample app not completely updated to Play 2.4 #277

Closed slimandslam closed 8 years ago

slimandslam commented 8 years ago

If you uncomment lines 175 or 176 in this file:

https://github.com/joscha/play-authenticate/tree/master/samples/java/play-authenticate-usage/app/models/User.java

The compilation of the sample app will fail with:

[error] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/User.java:175: cannot find symbol [error] symbol: method saveManyToManyAssociations(java.lang.String) [error] location: variable user of type models.User [error] user.saveManyToManyAssociations

slimandslam commented 8 years ago

The solution is to make sure these are in place:

import com.avaje.ebean.Ebean; import com.avaje.ebean.Model;

then change the syntax of:

user.saveManyToManyAssociations("roles");

to

Ebean.saveManyToManyAssociations(user, "roles");

slimandslam commented 8 years ago

If you turn on deprecation warnings on the sample app, you get this.

[warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/TokenAction.java:11: play.db.ebean.Model in play.db.ebean has been deprecated [warn] play.db.ebean.Model [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/SecurityRole.java:21: play.db.ebean.Model in play.db.ebean has been deprecated [warn] play.db.ebean.Model [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/TokenAction.java:18: play.db.ebean.Model in play.db.ebean has been deprecated [warn] Model [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/TokenAction.java:57: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new Finder<Long, TokenAction>( [warn] Long.class, TokenAction.class) [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/User.java:64: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new AppModel.Finder<Long, User>( [warn] Long.class, User.class) [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/SecurityRole.java:28: play.db.ebean.Model in play.db.ebean has been deprecated [warn] Model [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/SecurityRole.java:39: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new Finder<Long, SecurityRole>( [warn] Long.class, SecurityRole.class) [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/LinkedAccount.java:26: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new Finder<Long, LinkedAccount>( [warn] Long.class, LinkedAccount.class) [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/UserPermission.java:24: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new AppModel.Finder<Long, UserPermission>( [warn] Long.class, UserPermission.class)

joscha commented 8 years ago

Cool, would you mind making a PR for this? You could also enable deprecation warnings in it, so in the future we will see problems like this earlier! On 9 Sep 2015 6:20 am, "J Levitt" notifications@github.com wrote:

If you turn on deprecation warnings on the sample app, you get this.

[warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/TokenAction.java:11: play.db.ebean.Model in play.db.ebean has been deprecated [warn] play.db.ebean.Model [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/SecurityRole.java:21: play.db.ebean.Model in play.db.ebean has been deprecated [warn] play.db.ebean.Model [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/TokenAction.java:18: play.db.ebean.Model in play.db.ebean has been deprecated [warn] Model [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/TokenAction.java:57: Finder(java.lang.Class

,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new Finder( [warn] Long.class, TokenAction.class) [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/User.java:64: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new AppModel.Finder( [warn] Long.class, User.class) [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/SecurityRole.java:28: play.db.ebean.Model in play.db.ebean has been deprecated [warn] Model [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/SecurityRole.java:39: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new Finder( [warn] Long.class, SecurityRole.class) [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/LinkedAccount.java:26: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new Finder( [warn] Long.class, LinkedAccount.class) [warn] /play-authenticate-master/samples/java/play-authenticate-usage/app/models/UserPermission.java:24: Finder(java.lang.Class,java.lang.Class) in com.avaje.ebean.Model.Finder has been deprecated [warn] new AppModel.Finder( [warn] Long.class, UserPermission.class)

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

slimandslam commented 8 years ago

The solution to the Finder deprecation warnings is to change all the statements that use Finder from this:

public static Finder<Long, MyFile> find = new Finder<Long, MyFile>(Long.class, MyFile.class);

To this:

public static Finder<Long, MyFile> find = new Finder<Long, MyFile>(MyFile.class);

slimandslam commented 8 years ago

I'm pretty sure the other deprecation warnings can be eliminated by changing the import from this:

import play.db.ebean.Model

to

import com.avaje.ebean.Model

slimandslam commented 8 years ago

All of the Play-Authenticate routines in the onStart method in the app/Global.java file need to be migrated per instructions here: https://www.playframework.com/documentation/2.4.x/GlobalSettings

slimandslam commented 8 years ago

Add the latest version of deadbolt to your build.sbt file. It produces the least amount of logging noise:

"be.objectify" %% "deadbolt-java" % "2.4.3"

joscha commented 8 years ago

fixed in aaaecd5