New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UserProvider class not found - Play 2.4.x with Ebean 6.8.1 and play-ebean-2.0.0 #423
Comments
On Thu, Sep 24, 2015 at 5:44 AM, corrspt notifications@github.com wrote:
/Daryl |
Hi Daryl, thanks for replying! Well, Rob certainly deserves his vacations so we'll just wait for him to come back 👍 Meanwhile, from the discussions I found on the link I posted before, it seems the solution would be (somehow) to pass a classloader instance to the ClassUtil class. I'm not quite sure how would we do that without code (for instance in an application bootstrap process). I did try somethings on Play's onStart / beforeStart methods (like creating an instance of the UserProvider and setting it up in the serverConfig) but sometime later some code would again initialize the EbeanServer from the properties file (and this time around it didn't use my UserProvider instance). I thought it should only create the EbeanServer once but it seems not. |
Can you should how you went about doing that. Did you use ServerConfig.setCurrentUserProvider() ? |
Hey Rob, welcome back, hope you had a nice vacation! I apparently deleted the branch with this experiment, dumb me. I was trying to replicate the behavior again but I've stumbled upon a different error (one I remember I had before I reached the point which led to me create the issue). As I said, I'm using the Play-Framework with the Play-ebean plugin Plugins.sbt I've used this as an implementation of the CurrentUserProvider package com.myproject.ebean;
public class UserIdProvider implements CurrentUserProvider {
public UserIdProvider() {}
@Override
public Object currentUser() {
return Session.getCurrentAccountId(); //Returns a long
}
} I've tried both approaches, having this in my ebean.properties: And something like this (application.conf) And the content of the class being something like this import play.*;
public class Global extends GlobalSettings {
public void onStart(Application app) {
ServerConfig config = new ServerConfig();
config.setName("default");
config.loadFromProperties();
config.setCurrentUserProvider(new UserIdProvider());
config.setDefaultServer(true);
EbeanServerFactory.create(config);
}
} The thing I've noticed is that I've had various troubles trying to make Ebean work standalone, meaning without the play-ebean plugin (especially the enhancer part, I've even built from source the eclipse plugin at it was logging that enhancements were being made, but the play application did not pick them up. I suppose it's because it uses some sort of different mechanism to load classes). I've had this on the onStart as well
I'm now getting this stack trace.
Isn't the Ebean Server supposed to be a singleton? The problem here seems to be that my server configuration is being discarded and a new one is being created. Any ideas? |
> The problem here seems to be that my server configuration is being I think what you are doing in public class Global is in conflict with That is, I think that DefaultEbeanConfig.parse() method is where the > I've tried both approaches, having this in my What happens in that case? On 1 October 2015 at 20:38, corrspt notifications@github.com wrote:
|
Makes sense what you say about the ServerConfig being created there on I've tried again setting the currentUserProvider in the ebean.properties file (which is under my conf directory) but to no avail. I do get the same error as before. One interesting thing though, I added that same property in the
Trying to figure out what I can do through the application.conf file, maybe that's the trick. |
> I do get the same error as before. What was that error? On 1 October 2015 at 21:16, corrspt notifications@github.com wrote:
|
Sorry Rob, should've made it more clear. Thanks for the help (and sorry for making your life harder) This error
|
I'm not sure where we are at with this issue. If this issue relates to the need to use the context classLoader to create the CurrentUserProvider instance when using properties ... then this might be fixed with #476. |
Sorry for the late reply @rbygrave. Thanks for remembering this. I'm using the play-ebean plugin which in the latest stable release uses version 6.8.1 of Ebean (I see that they have a 3.0.0M1 release on github which seems to upgrade to version 6.10.3 of Ebean, I could try that). I can try to fork the play-ebean and upgrade locally to check if things work, but then I couldn't deploy to Heroku because of the fork not being on maven central, I think! Can I just include the latest ebean on my build.sbt to try it out? I understand this might not be your area of expertise, but I ask anyway as you may know. I'll try opening an issue with play-ebean to know more about how to upgrade the included library. I'm currently short on time, but I would like to give feedback on this. The biggest hurdle is how to upgrade to the latest ebean. Thanks again for the great work on Ebean, I'm very fond of it. EDIT: |
Yes. You might be able to just include the latest ebean on my build.sbt. There was a need to fork the play-ebean project as there was some API changes that occurred so some changes were needed in play-ebean ... it might be that is not required now and that just getting the newer dependency will be sufficient. So yes, not sure I'm afraid. |
Sorry for the very very late reply to this. I've tried to upgrade Ebean directly on my play project (overriding the one used by play ebean) and it works so I tried this afterward and the problem didn't occur, so I'm closing this issue. I can't upgrade yet because the code I had to generate the ddl migrations is not recognizing my previous migration files, but that is probably some mistake I did, I presume. Thanks a lot for everything @rbygrave |
Hi
I've been trying to setup Ebean 6.8.1 with the latest Play Framework, which was made possible yesterday with update of the play-ebean (version 2.0.0) plugin. I'm having trouble with the @ WhoUpdated / @ WhoCreatedAnnotation, because Ebean says it cannot find my Class
This is the Stacktrace
I did some debugging and found out that the classloader used had this info - Which does not seem to include my
src
directories (app/conf/test) and so makes sense that it cannot find my class.I've tried setting the ServerConfig class with the implementation of my UserProvider on application startup but to no avail. Any ideas?
I've found this discussion regarding the use of Class.forName in play framework / libraries if that helps.
The text was updated successfully, but these errors were encountered: