0

我在 Play 2.0.4 中有一个独立的工作,我想在 Heroku 上运行,如https://github.com/jamesward/play2-scheduled-job-demo中所述 我启动应用程序就像在示例中一样:

public class QueueWorker {
    public static void main(String[] args) {
        Application application = new Application(new File(args[0]), QueueWorker.class.getClassLoader(), null, Mode.Dev());
        Play.start(application);
    }
}

但是现在,从日志来看,Play 出于某种原因连接了两次数据库,而 EhCache 第二次失败了,因为它的名称已经注册:

[[37minfo[0m] play - database [default] connected at jdbc:mysql://localhost/myproject?characterEncoding=UTF-8
[[37minfo[0m] play - database [default] connected at jdbc:mysql://localhost/myproject?characterEncoding=UTF-8
Exception in thread "main" net.sf.ehcache.ObjectExistsException: Cache play already exists
    at net.sf.ehcache.CacheManager.addCache(CacheManager.java:990)
    at play.api.cache.EhCachePlugin.x$3(Cache.scala:111)
    at play.api.cache.EhCachePlugin.cache(Cache.scala:109)
    at play.api.cache.EhCachePlugin.onStart(Cache.scala:127)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:60)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:60)
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
    at scala.collection.immutable.List.foreach(List.scala:45)
    at play.api.Play$.start(Play.scala:60)
    at play.api.Play.start(Play.scala)
    at jobs.QueueWorker.main(QueueWorker.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

有趣的是,当我使用“play run”命令启动项目时,这不会发生。有没有人向我暗示这可能是什么,或者我如何调试它的来源?

4

1 回答 1

0

As it turns out the problem lies with the play-authenticate module. Even if you remove all entries from play.plugins and just let it sit in your dependencies, it will generate this kind of error. I created an error report at https://github.com/joscha/play-authenticate/issues/23 and hope it will be fixed soon.

于 2012-10-15T13:11:06.147 回答