play-plugins icon indicating copy to clipboard operation
play-plugins copied to clipboard

Mailer plugin prevents standalone execution

Open keyboardsamurai opened this issue 13 years ago • 7 comments

If you add the typesafe mailer plugin to Build.scala on a new play 2.0.3/2.0.4 project, you lose the ability to execute standalone play apps that start the framework programatically.

For example you create a new Application, and add this to Build.scala

"com.typesafe" %% "play-plugins-mailer" % "2.0.4"

Then create this class:

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

Compile and recreate IDE settings, and then execute said class, you get the following error:

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)

This issue originated here https://github.com/joscha/play-authenticate/issues/23

keyboardsamurai avatar Oct 18 '12 15:10 keyboardsamurai

looks like you have two play jars on your classpath. Can you figure out what's bringing in the 2nd jar?

pk11 avatar Oct 18 '12 16:10 pk11

http://repo.typesafe.com/typesafe/releases/com/typesafe/play-plugins-mailer_2.9.1/2.0.4/play-plugins-mailer_2.9.1-2.0.4.pom (notice that play jar is defined as provided)

pk11 avatar Oct 18 '12 16:10 pk11

Good catch. Searching for the duplicates in the classpath led me to believe that there is something wrong with the "play idea" command. "play eclipsify" seems to work even if I add the plugin. Why would the mailer plugin be the only plugin I could find, that triggers this bug in the idea project generator though?

keyboardsamurai avatar Oct 18 '12 16:10 keyboardsamurai

I can't find a duplicate play_2.9.1.jar file in the .idea/libraries descriptors and the dependency list doesn't show any duplicates either.

keyboardsamurai avatar Oct 18 '12 17:10 keyboardsamurai

unfortunately I can not replicate this issue. You usually see this error message if you have two play jars on your classpath (and therefore two play.plugins files). Since the plugin is not brining in any play jars, i can not see how this can be related to the plugin

pk11 avatar Oct 18 '12 17:10 pk11

Thank you Peter, for pointing me in the right direction. The play.plugins file is on the classpath twice because both play_2.9.1.jar and play_2.9.1-sources.jar are included into the dependencies when "play idea" is executed. For some reason the play.plugins within play_2.9.1-sources.jar gets picked up and causes havoc. If I remove play_2.9.1-sources.jar from the path everything is fine.

Removing the plugin from Build.scala and re-generating the idea descriptors removes the sources. That doesn't seem right either. Any suggestion what should be done about this? I guess this will trip up quite a few people.

keyboardsamurai avatar Oct 19 '12 08:10 keyboardsamurai

That's good to know! I will look into how to get rid of that file from the XXXsources.jar

pk11 avatar Oct 19 '12 12:10 pk11