[2.1-SNAPSHOT] ObjectExistsException: Cache play already exists

3,200 views
Skip to first unread message

Gilbert Wong

unread,
Aug 12, 2012, 11:52:11 PM8/12/12
to play-fr...@googlegroups.com
is it because I have 2 play jar files in my classpath?
> play classpath
...
- D:\lib\play\repository\local\play\play_2.9.2\2.1-SNAPSHOT\jars\play_2.9.2.jar
...
- D:\lib\play\repository\local\play\play_2.9.1\2.0.2\jars\play_2.9.1.jar

if so, how can I remove it?

FYI, I've already ran `play clean` and `play eclipse` inside the project.

Thanks.

virtualeyes

unread,
Sep 18, 2012, 12:51:38 PM9/18/12
to play-framework
Same deal here, a play plugin setup classpath entries for its own
embedded play jar, and now getting "Cache play already exists"

How can I blow away these classpath entries? (got rid of the offending
plugin)

Have tried play clean update reload, but classpath remains the same.
Can see .classpath contains the old plugin's jar references, and local
repo cache has all the offending plugin's jars.

Is there some sbt magic command here that will do the trick to get
classpath to actual current state of the app and not hang on to old
references?

Thanks

virtualeyes

unread,
Sep 18, 2012, 1:16:22 PM9/18/12
to play-framework
Blew away local repo cache/*

and then "/projectDir# play" wouldn't load

did a "/projectDir# sbt clean update reload clean-files"

and then "/projectDir# play" loaded

play> eclipse skip-parents=false

and back in business, .classpath files updated for all sub projects --
offending plugin and its mess o' jars utterly gone...



On Aug 13, 5:52 am, Gilbert Wong <jaguar.fen...@gmail.com> wrote:

virtualeyes

unread,
Sep 18, 2012, 1:29:46 PM9/18/12
to play-fr...@googlegroups.com
Issue itself is not resolved, however.

Must be a conflict with sub projects and Cache implementation.

For now "ehcacheplugin=disabled" at least gets the app running in dev mode.

Of course, I was intending on using it, so looks like give Redis plugin a shot, or hope someone chimes in with the good word on how to actually get Play Cache working in a multi-project app...

James Roper

unread,
Sep 18, 2012, 10:49:33 PM9/18/12
to play-fr...@googlegroups.com
These multiple jars should not be of concern, they are not all on the classpath, this is simply your local ivy repository, which contains all jars that you (or a script) have deployed to it.  Only the jars that Play is actually configured to use will end up on your classpath.

Now, could you explain the exact steps you took to get this exception?  Some logs/stack traces would be nice.

virtualeyes

unread,
Sep 19, 2012, 2:43:23 AM9/19/12
to play-fr...@googlegroups.com
James, Hi.

Ok, so sounds like this will work in production, but not yet in devel (stacktrace at end of this message)

I built against 2.1 snapshot from @3 days ago as per building from source guide. plugins.sbt looks like:
resolvers ++= Seq(
  Resolver.url( "publishTo", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/" ))(Resolver.ivyStylePatterns),
  Resolver.file( "Local Repository", file("/home/foo/bar/Play21/repository/local" ))(Resolver.ivyStylePatterns),
  "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)
addSbtPlugin("play" % "sbt-plugin" % "2.1-SNAPSHOT")

I then followed the multi-project guide, doing something like the following in Build.scala:
lazy val root  = PlayProject(appName + "-root", appVersion, rootDeps, path = file("root"), mainLang = SCALA)
lazy val model = PlayProject(appName + "-data", appVersion, dataDeps, path = file("model"), mainLang = SCALA) dependsOn(root)
lazy val main  = PlayProject(appName + "-app", appVersion, appDeps, path = file("gate"), mainLang = SCALA) dependsOn(root,model) aggregate(root,model)

So main is the entry point (I don't need root or model to be accessible as Play applications, just some odds & ends like I18N, Form, etc. to serve as a base for main)

It is unclear to me how Play aggregates the projects together, particularly around routes, application.conf and any other conf related file (logback.xml, etc.).  I assume the last one standing wins (main in this case)

At any rate, Play Cache is really useful ;-) Was thinking about standing up a VMware ESXi *nix instance to run Redis (using Play Redis plugin) over LAN, but that was not on my direct must-do-now list; it will be if I can't get Play cache working in devel, however.

Keep posted if you have any clue as to how I can workaround the issue.

Thanks

*********************
play.api.UnexpectedException: Unexpected exception [ObjectExistsException: Cache play already exists]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3$$anonfun$1.apply(ApplicationProvider.scala:125) ~[play_2.9.2.jar:2.1-SNAPSHOT]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3$$anonfun$1.apply(ApplicationProvider.scala:103) ~[play_2.9.2.jar:2.1-SNAPSHOT]
    at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.12.0]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3.apply(ApplicationProvider.scala:103) ~[play_2.9.2.jar:2.1-SNAPSHOT]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$3.apply(ApplicationProvider.scala:101) ~[play_2.9.2.jar:2.1-SNAPSHOT]
    at scala.Either$RightProjection.flatMap(Either.scala:520) ~[scala-library.jar:0.12.0]
Caused by: net.sf.ehcache.ObjectExistsException: Cache play already exists
    at net.sf.ehcache.CacheManager.addCache(CacheManager.java:990) ~[ehcache-core-2.5.0.jar:na]
    at play.api.cache.EhCachePlugin.x$1(Cache.scala:122) ~[play_2.9.2.jar:2.1-SNAPSHOT]
    at play.api.cache.EhCachePlugin.cache(Cache.scala:120) ~[play_2.9.2.jar:2.1-SNAPSHOT]
    at play.api.cache.EhCachePlugin.onStart(Cache.scala:138) ~[play_2.9.2.jar:2.1-SNAPSHOT]
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:62) ~[play_2.9.2.jar:2.1-SNAPSHOT]
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:62) ~[play_2.9.2.jar:2.1-SNAPSHOT]
*********************

James Roper

unread,
Sep 20, 2012, 1:23:57 AM9/20/12
to play-fr...@googlegroups.com
Ok, we've got a few bugs here.

1) Ehcache stores a reference to each cache manager, by name, that it creates.  If you try and create another one with the same name, it doesn't create it, it returns the original one.  This is a pile of suck, because it means the Play ehcache plugin can't "own" it's own cache manager, it has to share it with whatever else wants to use a cache manager with the same name. But there's not much we can do about this right now.
2) The play cache manager is either not being shut down when a reload is done, or it is being started twice.  I suspect it might be being started twice, or that there are somehow two instances of the play cache plugin configured.  I can't tell you why this would be, because I don't know.  But what would help is if you could create a Global.java or Global.scala, as per http://www.playframework.org/documentation/2.0.3/JavaGlobal or http://www.playframework.org/documentation/2.0.3/ScalaGlobal, and implement onStart/onStop by logging some output.  Then start play, and tell me what you see.  Then we'll be one step closer to the answer.  If you happen to have good debug-foo, you could get in there yourself, and work out what's happening, if there's multiple ehcache plugins or what the problem is.

Cheers,

James

virtualeyes

unread,
Sep 20, 2012, 10:42:06 AM9/20/12
to play-fr...@googlegroups.com
James, thanks

I like that, "a pile of suck", great expression ;-)

I'll implement onStart/Stop in Global.scala and see what comes up.

On a related note, I don't need the Play kitchen sink for root & model sub projects, just odds & ends from Play jar like I18N, Form, etc. However, if I create plain SBT projects instead of PlayProjects for root and model, and include Play 2.1 snapshot jar on the classpath, then the lone PlayProject, main, complains on startup about there being duplicate 2.1 snapshot jars.

That road (2 SBT + 1 PlayProject) seems to contain perhaps more suck than going with 3 PlayProjects, so am rolling with the latter.

Will post back with results in awhile...

virtualeyes

unread,
Sep 20, 2012, 12:17:32 PM9/20/12
to play-fr...@googlegroups.com
onStart is not getting picked up (or not getting to that point) with play "~run", errors out with already given error trace...

James Roper

unread,
Sep 20, 2012, 9:07:43 PM9/20/12
to play-fr...@googlegroups.com
On a related note, I don't need the Play kitchen sink for root & model sub projects, just odds & ends from Play jar like I18N, Form, etc. However, if I create plain SBT projects instead of PlayProjects for root and model, and include Play 2.1 snapshot jar on the classpath, then the lone PlayProject, main, complains on startup about there being duplicate 2.1 snapshot jars.

This is telling, looks like there must be multiple plugin resources declaring the ehcache plugin on the classpath, and this will definitely cause your problem.  There are a few fixes I think that need to be done here, one is work out why there are duplicate jars on the classpath and fix that, the other is to probably filter out duplicate plugin declarations, or fail with an error if they exist, or at least give a warning.

I actually haven't look at multi module stuff in Play before, if there are other Play devs that understand this better than me and can see a simple problem here, please speak now, before I go and try and replicate this issue myself.
Reply all
Reply to author
Forward
0 new messages