Skip to content
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

Hot-reloading doesn't work if there are multiple ebean datasources #792

Closed
thomasguo opened this issue May 24, 2017 · 0 comments
Closed
Milestone

Comments

@thomasguo
Copy link

thomasguo commented May 24, 2017

When we put 2 or more ebean datasources in an application, the hot-reloading doesnt work. For example:

In application.conf :

## default dataSource
db.url = "jdbc:mysql://127.0.0.1:3306/star-web?useUnicode=true&characterEncoding=utf8"
db.user = xxxxxx
db.password = xxxxxx
## another dataSource
centreDB.url = "jdbc:mysql://127.0.0.1:3306/star-centre?useUnicode=true&characterEncoding=utf8&databaseName=centre"
centreDB.user = xxxxxx
centreDB.password = xxxxxx

In startup MyApp.java :

{
        //.....
        use(new Ebeanby().doWith((ServerConfig cfg) -> {
            cfg.addPackage("xxx.star.web");
        }));
        use(new Ebeanby("centreDB").doWith((ServerConfig cfg) -> {
            cfg.addPackage("xxx.star.centre");
            cfg.setDefaultServer(false); 
        }));
        //.....
        get("/", (req) -> "Hello World!");
}

And start the application with 'mvn clean jooby:run' . If change any code, the hot-reload begins and throw an exception like following:

[2017-05-24 10:08:45,932]-[HotSwap] ERROR xxx.star.MyApp - An error occurred while starting the application:
com.google.inject.CreationException: Unable to create injector, see the following errors:

1) No implementation for org.jooby.spi.HttpHandler was bound.
  while locating org.jooby.spi.HttpHandler
    for the 1st parameter of org.jooby.internal.undertow.UndertowServer.<init>(UndertowServer.java:66)
  at org.jooby.undertow.Undertow.configure(Undertow.java:35)

2) An exception was caught and reported. Message: java.lang.NoClassDefFoundError: Could not initialize class sun.tools.attach.WindowsVirtualMachine
  at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)

2 errors
	at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:470)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
	at com.google.inject.Guice.createInjector(Guice.java:99)
	at com.google.inject.Guice.createInjector(Guice.java:84)
	at org.jooby.Jooby.lambda$new$0(Jooby.java:683)
	at org.jooby.Jooby.bootstrap(Jooby.java:2741)
	at org.jooby.Jooby.start(Jooby.java:1954)
	at org.jooby.Jooby.start(Jooby.java:1935)
	at org.jooby.Jooby.run(Jooby.java:1865)
	at xxx.star.MyApp.main(MyApp.java:108)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.jooby.run.Main.lambda$startApp$1(Main.java:242)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javaslang.control.Try$FatalException: java.lang.NoClassDefFoundError: Could not initialize class sun.tools.attach.WindowsVirtualMachine
	at javaslang.control.Try$NonFatalException.of(Try.java:885)
	at javaslang.control.Try$Failure.<init>(Try.java:754)
	at javaslang.control.Try$Failure.<init>(Try.java:739)
	at javaslang.control.Try.run(Try.java:55)
	at org.jooby.Jooby.lambda$bootstrap$50(Jooby.java:2666)
	at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
	at com.google.inject.spi.Elements.getElements(Elements.java:110)
	at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
	... 18 common frames omitted
Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.tools.attach.WindowsVirtualMachine
	at org.avaje.agentloader.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:321)
	at org.avaje.agentloader.AgentLoader.loadAgent(AgentLoader.java:91)
	at org.jooby.internal.ebean.EbeanAgentEnhancer.run(EbeanAgentEnhancer.java:57)
	at org.jooby.ebean.Ebeanby.lambda$configure$1(Ebeanby.java:192)
	at org.jooby.jdbc.Jdbc.configure(Jdbc.java:367)
	at org.jooby.ebean.Ebeanby.configure(Ebeanby.java:187)
	at org.jooby.Jooby.install(Jooby.java:3132)
	at org.jooby.Jooby.lambda$bindService$52(Jooby.java:2821)
	at org.jooby.Jooby.lambda$null$47(Jooby.java:2677)
	at javaslang.control.Try.run(Try.java:52)
	... 23 common frames omitted
>>> jooby:run[error|HotSwap]: xxx.star.MyApp.start() resulted in error
java.lang.NullPointerException
	at org.jooby.run.Main.lambda$startApp$1(Main.java:247)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants