-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
cannot start in PROD mode when assigning port explicitly with ebean #457
Comments
Hello @wei-hai, could you please provide a small project that shows this problem? I was not able to reproduce this. Also, the mailing list would be a better place to discuss this. Github issues are for reporting bugs and feature requests in Play, not for general discussion and getting help. So, if this is more a doubt than a reproducible bug, I encourage you to move the discussion to the mailing list. |
I'm having this exact same problem using 2.6. |
For me too, after removing one of the parameters from initialization command the error was gone. |
I have the same problem than seems I switched to Play 2.6.0-RC2 and Ebean 4.0.0-M3. The error seems more "random" to me, because it happens randomly in development and in prod...
|
Hi, I was not able to reproduce it using Play 2.6.0 RC2 and play-ebean 4.0.0-RC1. Here are the changes that I've made to https://github.com/joaocraveiro/versus: diff --git a/project/plugins.sbt b/project/plugins.sbt
index 624e4c5..f281054 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -1,4 +1,4 @@
// The Play plugin
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.0-M5")
+addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.0-RC2")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
-addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.0.0-M3")
+addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.0.0-RC1") After that: export PORT=9000
export DATABASE_URL="jdbc:postgresql://localhost/issue_7017"
export JDBC_DATABASE_USERNAME=postgres
export JDBC_DATABASE_PASSWORD=dummy
export JDBC_DATABASE_URL="jdbc:postgresql://localhost/issue_7017"
sbt clean stage
foreman start And I get the application running: 17:58:48 web.1 | started with pid 37604
17:58:50 web.1 | [info] application - Creating Pool for datasource 'default'
17:58:50 web.1 | [warn] c.z.h.HikariConfig - The initializationFailFast propery is deprecated, see initializationFailTimeout
17:58:50 web.1 | [info] p.a.d.DefaultDBApi - Database [default] connected at jdbc:h2:mem:play_env
17:58:51 web.1 | [info] application - Starting module...
17:58:51 web.1 | [info] application - Profiles: 1
17:58:51 web.1 | [warn] o.h.v.m.ParameterMessageInterpolator - HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
17:58:51 web.1 | [info] play.api.Play - Application started (Prod)
17:58:51 web.1 | [info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 @joaocraveiro do you have environment variables for You can better figure out what is happening in your application by adding the following <configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- We use short exception stack trace logging to limit output for travis. -->
<!-- Change to full if you need to do further debugging, but never commit that. -->
<pattern>%level %logger{15} - %message%n%ex{short}</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration> @wei-hai and @Flo354 could you also please try with the new versions of Play and play-ebean and with a more verbose log? |
@marcospereira evolutions were ok and yes I do have those variables but never had the problem running locally (maybe because I don't use any variables in the command to start the server locally, I read them all from the conf file, while on Heroku I need to so it can bind the database configs automatically). I'd guess it was a problem with either the length of the start command or a conflict between variables in both the start command and in the conf file. |
@marcospereira please explain this line:
I see it in my console, and I don't know what does it mean |
I found and fixed the problem for my crash. There were conflicts with versions... Solved by doing this in my build.sbt libraryDependencies ++= Seq(
...
"com.typesafe.play" % "play-jdbc_2.12" % "2.6.0-RC2",
"com.typesafe.play" % "play-jdbc-api_2.12" % "2.6.0-RC2",
"com.typesafe.play" % "play-jdbc-evolutions_2.12" % "2.6.0-RC2",
"com.typesafe.play" % "play-java-jdbc_2.12" % "2.6.0-RC2"
)
dependencyOverrides ++= Set(
"com.typesafe.play" % "play-jdbc_2.12" % "2.6.0-RC2",
"com.typesafe.play" % "play-jdbc-api_2.12" % "2.6.0-RC2",
"com.typesafe.play" % "play-jdbc-evolutions_2.12" % "2.6.0-RC2",
"com.typesafe.play" % "play-java-jdbc_2.12" % "2.6.0-RC2"
) |
@PromanSEW This warning is from Hibernate Validator. We removed the |
@Flo354 this was happening because play-ebean was bringing the wrong (old) Play dependencies. This should be working now since it is depending on the right Play version. I'm closing this issue. |
The error surfaced again (play 2.6.2)... I did not have the problem when starting the project in dev mode but when I pushed the app to my production servers, it did not work. Still the same "Error trying to create the default EbeanServer" Here is the stack trace from CloudWatch :
EDIT : it seems again that play-ebean bring the old play dependencies... 2.6.0 are presents instead of 2.6.2. Fixed with : dependencyOverrides ++= Set(
"com.typesafe.play" % "play-jdbc_2.12" % "2.6.2",
"com.typesafe.play" % "play-jdbc-api_2.12" % "2.6.2",
"com.typesafe.play" % "play-jdbc-evolutions_2.12" % "2.6.2",
"com.typesafe.play" % "play-java-jdbc_2.12" % "2.6.2"
) |
Try to use sbt update before sbt dist. Maybe that is a cleaner solution instead of the dependencyOverrides approach. That solved it for me. Reproducible on two environments with the same problem. |
That's strange, I would have thought that dist already triggers an update... |
I expected it too, but it seems the update is not performed. When you change the dependency versions the files are not copied into the bundle in the correct version (check the lib folder). Only manual dist update solves it. Reproducible with Play 2.6.x on two systems. |
Been facing this for a while, and it happens really randomly too, but the above responses did not help me but instead, updating the
in I think this should be reopened because these random fixes + it still happening randomly means it must be more then just dependency issues. I know its flaky and only reproducible for a selected few so I don't know how to approach it :/ Update: Specifically, doing |
After banging my head against this issue for way too long, I have a theory. This is running play 2.6.7, but I think it probably applies to earlier versions as well. The The Play framework (at least in most examples) tries to create EbeanServers according to application config in The thing that I think bites many people is that the examples, Since, afaik, Guice has no pre-defined order when instantiating classes, the repository class might be created before the I have been able to make this error stop happening by starting to use the public class UserRepository {
private final String ebeanServer;
private final DatabaseExecutionContext executionContext;
@Inject
public UserRepository(EbeanConfig ebeanConfig, DatabaseExecutionContext executionContext) {
this.ebeanServer = ebeanConfig.defaultServer();
this.executionContext = executionContext;
}
public CompletionStage<Void> insert(User user) {
return supplyAsync(
() -> {
Ebean.getServer(ebeanServer).insert(user);
return null;
},
executionContext);
}
} I believe that either the docs should be updated with this, or that the race condition at DI should be resolved somehow. I don't know which though 😉 |
Reading up on the original reporter's issue, I think that my 'theory' was for a different bug than what was originally reported, but with the same symptoms. Might still be valid for others though. |
In addition to @antonha answer, his solution didn't entirely work in my case. I think @antonha is right about the race condition, so I started ebean server from guice module.
And here's the module: public class Module extends AbstractModule {
private final Environment environment;
private final Config config;
public Module(
Environment environment,
Config config
) {
this.environment = environment;
this.config = config;
}
@Override
protected void configure() {
ServerConfig ebeanConfig = new ServerConfig();
DataSourceConfig db = new DataSourceConfig();
db.setDriver(config.getString("db.default.driver"));
db.setUsername(config.getString("db.default.username"));
db.setPassword(config.getString("db.default.password"));
db.setUrl(config.getString("db.default.url"));
ebeanConfig.setDefaultServer(true);
ebeanConfig.setDataSourceConfig(db);
EbeanServerFactory.create(ebeanConfig);
// ... rest of the bindings
}
} |
Essentially it's not loading the EbeanDynamicEvolutions private final EbeanServer ebeanServer;
private final DatabaseExecutionContext executionContext;
private final EbeanDynamicEvolutions ebeanDynamicEvolutions;
@Inject
public YourRepository(EbeanConfig ebeanConfig, EbeanDynamicEvolutions ebeanDynamicEvolutions, DatabaseExecutionContext executionContext) {
this.ebeanDynamicEvolutions = ebeanDynamicEvolutions;
this.ebeanServer = Ebean.getServer(ebeanConfig.defaultServer());
this.executionContext = executionContext;
} Taken from in here :: #51 |
Can confirm, this still occurs with Play 2.6.11. Should be reopened. |
This is a really huge problem that needs to be solved. Also occuring on Play 2.6.12 and play-ebean 4.1.0. Even in development mode sometimes. In development mode it helps by restarting the MySQL server and then compile the app again. After that it works. But that's not possible in a live environment. |
Confirmed. It is still happening with Play 2.6.12 and play-ebean 4.1.0. Last solution from @rowanl worked, however it is still workaround. |
Reopening since there are multiple reports against new versions of Play and play-ebean. |
On my MacBook Pro 2017 my Play 2.6.12 App has the mentioned problems using play-ebean 4.1.0. On this machine it helped downgrading to 4.0. On a Linux machine it's the other way around. The same code showed the known problems, but on this machine upgrading to play-ebean 4.1.0 helped. |
@GBeushausen thank you for the additional information. |
Occurred again in production environment. Not reproducible on dev environment. @rowanl workaround is not working. Play 2.6.12. ebean configuration:
Logs: |
Applied @rowanl's workaround to all of my repositories, now the app is starting again in production environment. |
I just solved this error by change db.default.user to db.default.username. I hope this helps |
I still have the error with play 2.6.13 and play ebean 4.1.0 (no errors with 4.0.6). But I have the error in development. See my issue on the play-ebean repo: #145 |
We had the same problem using play 2.6.13, play-ebean 4.1.0. This issue only happens publishing with docker (
Edit: An update 7 days later. This issue is very random, now this happened again even publishing with stage. Edit2: for now, injecting If this is a race condition caused by a wrong injection with guice... we are considering to change our project to use dagger2 instead. It is so annoying how you cant be sure that your code will works as always because of runtime errors. |
I just fixed my problem. I have two databases, While, this page https://www.playframework.com/documentation/2.6.x/JavaEbean tells: The property to define is not Found this here: https://stackoverflow.com/a/31070658 |
We have been injecting databaseExecutionContext throughout our code for maintaining a threadpool for database connections. |
Confirming that I see this issue in Play 2.7.3 + play-ebean 5.0.0 CloudWatch logs:
|
Am I missing something? This issue is 2 years old and I only see a work-around. I can confirm this is sporadic and unpredictable. Been running without issue for months, and in an instant all of a sudden deployments start failing on startup because of:
EbeanServerProvider.java
GuiceModule: application.properties:
|
Hey everyone, is this still a problem with newer Play and play-ebean releases? |
ahahaha, great timing. I am in process of updating the old project were I got this error back then, just right now. Idk if with the current version of play-ebean 8.2.0 (with ebean 15.x) this would be fixed, but I will be testing for the next weeks to see. |
@ErunamoJAZZ Great! Looking forward to your feedback. |
Play Version (2.5.x / etc)
2.5.x
API (Scala / Java / Neither / Both)
Java
Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)
CentOS 7
JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)
openJDK 1.8.x
Library Dependencies
ebean
Expected Behavior
when I run:
The application works well.
However, when I run:
application cannot start.
Please describe the expected behavior of the issue, starting from the first action.
Actual Behavior
The text was updated successfully, but these errors were encountered: