Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Module prevents standalone/junit execution #23

Closed
keyboardsamurai opened this issue Oct 15, 2012 · 7 comments
Closed

Module prevents standalone/junit execution #23

keyboardsamurai opened this issue Oct 15, 2012 · 7 comments
Assignees
Labels

Comments

@keyboardsamurai
Copy link

This seems related to what is being described a little way down in #20 Each time you try to run Play from within a self contained Application, like so:

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);
    }
}

(a standalone job or a JUnit test class) you get an Exception coming from the EhCache provider:

--> [�[37minfo�[0m] play - database [default] connected at jdbc:h2:mem:play
[�[37minfo�[0m] play - database [default] connected at jdbc:h2:mem:play
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:13)
    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)

I can reproduce this behavior on play 2.0.3 and play 2.0.4 on two different development machines. To reproduce, do the following steps:

  1. git clone https://github.com/joscha/play-authenticate.git
  2. Copy the QueueWorker class from above to play-authenticate/samples/java/play-authenticate-usage/app/jobs
  3. Launch QueueWorker with "." as a parameter from command line or Ide (or Procfile on Heroku)

Unfortunately this even happens, when you add the play-authenticate dependency 0.2.0-SNAPSHOT to Build.scala and configure nothing else.

@joscha
Copy link
Owner

joscha commented Oct 16, 2012

Can you try, if this happens when you only add play-easymail (http://joscha.github.com/play-easymail/) to your project as well? Just remove the play authenticate lines from the project definition and leave the play-easymail repos and add play-easymail to the dependencies

@ghost ghost assigned joscha Oct 16, 2012
@keyboardsamurai
Copy link
Author

I just created a new project, added play-easymail to Build.scala and I have a similar error. Please note that the two "play - database [default] connected at jdbc:h2:mem:play" messages are missing though.

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:13)
    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)

@joscha
Copy link
Owner

joscha commented Oct 17, 2012

I can't find where the problem is - https://groups.google.com/forum/?fromgroups=#!topic/play-framework/JrzkjVAV2nU suggests it might be duplicate jar entries in the classpath... Could you check if this does happen, if you only add typesafe mailer plugin as well?

@keyboardsamurai
Copy link
Author

Yes, I can confirm that with typesafe mailer plugin it's the same thing.

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:12)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

@joscha
Copy link
Owner

joscha commented Oct 18, 2012

Okay, so this is not a play-authenticate specific problem then - would you mind opening an issue here then: https://github.com/typesafehub/play-plugins/ ? You might want to reference this ticket, though.

@keyboardsamurai
Copy link
Author

Referenced issue on play-plugins playframework/play-plugins#46

@joscha
Copy link
Owner

joscha commented Oct 18, 2012

Thank you!

@joscha joscha closed this as completed Oct 18, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants