In a larger playframework 2.1.3 application, I started to use JClouds blobstorage. I added the dependencies
"org.apache.jclouds" % "jclouds-allblobstore" % "1.6.1-incubating",
"com.google.code.findbugs" % "jsr305" % "1.3.+"
and added an action running the following code
val action = Action {
val context = ContextBuilder.newBuilder("s3")
.endpoint("https://cs.hosteurope.de")
.credentials(username, password)
.buildView(classOf[BlobStoreContext])
Ok("success")
}
When I run this action, I get:
java.lang.IllegalArgumentException: Can not set javax.inject.Provider field
In more detail, I get
[CreationException: Guice creation errors: 1) Error in custom provider, java.lang.IllegalArgumentException: Can not set javax.inject.Provider field org.jclouds.blobstore.config.BlobStoreMapModule$BlobMapFactory.blobBuilders to com.google.inject.internal.InjectorImpl$4 at org.jclouds.blobstore.config.BlobStoreMapModule.configure(BlobStoreMapModule.java:50) while locating org.jclouds.blobstore.BlobMap$Factory Caused by: java.lang.IllegalArgumentException: Can not set javax.inject.Provider field org.jclouds.blobstore.config.BlobStoreMapModule$BlobMapFactory.blobBuilders to com.google.inject.internal.InjectorImpl$4 at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) at java.lang.reflect.Field.set(Field.java:680) at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:54) at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254) at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54) at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46) at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031) at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) at com.google.inject.Scopes$1$1.get(Scopes.java:65) at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40) at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:204) at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:198) at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024) at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:198) at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:179) at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109) at com.google.inject.Guice.createInjector(Guice.java:95) at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:405) at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:329) at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:620) at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:600) at controllers.admin.OtherController$$anonfun$7$$anonfun$apply$2.apply(OtherController.scala:40) at controllers.admin.OtherController$$anonfun$7$$anonfun$apply$2.apply(OtherController.scala:36) at controllers.admin.utils.MenuController$MenuAction.apply(Menu.scala:51) at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:109) at play.utils.Threads$.withContextClassLoader(Threads.scala:18) at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:108) at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:106) at scala.Option.map(Option.scala:145) at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2.apply(Action.scala:106) at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$2.apply(Action.scala:99) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:137) at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1417) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1478) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
To trace the problem, I created a completely new play app with the same library dependencies and then replaced the main action with the code above. That works perfectly well. And since I added all library dependencies of the large play app, I don't know what else in the larger app could break it.
What could cause that problem?
edit: Dependencies of the large app:
"mysql" % "mysql-connector-java" % "5.1.25",
"org.squeryl" %% "squeryl" % "0.9.5-6",
"net.sf.jasperreports" % "jasperreports" % "4.7.1",
"com.typesafe" %% "play-plugins-mailer" % "2.1.0",
"org.scalatest" %% "scalatest" % "2.0.M5b" % "test",
"jp.t2v" %% "play2.auth" % "0.9",
"jp.t2v" %% "play2.auth.test" % "0.9" % "test",
"org.scala-lang" % "scala-actors" % "2.10.0" % "test",
"com.unboundid" % "unboundid-ldapsdk" % "2.3.1",
"net.sf.uadetector" % "uadetector-resources" % "2013.06",
"org.apache.commons" % "commons-email" % "1.3.1",
"org.apache.jclouds" % "jclouds-allblobstore" % "1.6.1-incubating",
"com.google.code.findbugs" % "jsr305" % "1.3.+"
Very strange, it works when I move the two dependencies
to the top of the list. When they are at the bottom, it doesn't work. So
breaks, but
works.
Problem solved for me now. If anyone has ideas why order could be important though, I'd be curious.