neo-sbt-scalafmt icon indicating copy to clipboard operation
neo-sbt-scalafmt copied to clipboard

ClassNotFoundException - Multi Project build

Open etspaceman opened this issue 8 years ago • 8 comments

Hi there -

Ran into an odd issue when I was leveraging this in a multi-project build with scalafmtOnCompile := true. If I ran:

sbt "project someProject" clean reload compile

I would receive an exception (noted below).

However, if I ran:

sbt clean and then sbt "project someProject" reload compile

Things worked as intended. Not sure exactly what's going on here.

[error] java.util.concurrent.ExecutionException: java.lang.ClassNotFoundException: com.lucidchart.scalafmt.impl.ScalafmtFactory [error] at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:502) [error] at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:461) [error] at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:83) [error] at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:142) [error] at com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2453) [error] at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2417) [error] at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2299) [error] at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212) [error] at com.google.common.cache.LocalCache.get(LocalCache.java:4147) [error] at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4151) [error] at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5140) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$.$anonfun$buildSettings$4(ScalafmtCorePlugin.scala:234) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$.$anonfun$scalafmtCoreSettings$26(ScalafmtCorePlugin.scala:154) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:44) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:42) [error] at sbt.std.Transform$$anon$4.work(System.scala:64) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:257) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16) [error] at sbt.Execute.work(Execute.scala:266) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:257) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:167) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:32) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] Caused by: java.lang.ClassNotFoundException: com.lucidchart.scalafmt.impl.ScalafmtFactory [error] at java.net.URLClassLoader.findClass(URLClassLoader.java:381) [error] at com.lucidchart.sbt.scalafmt.BridgeClassLoader.findClass(BridgeClassLoader.scala:11) [error] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [error] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anon$1.load(ScalafmtCorePlugin.scala:230) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anon$1.load(ScalafmtCorePlugin.scala:227) [error] at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3708) [error] at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2416) [error] at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2299) [error] at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212) [error] at com.google.common.cache.LocalCache.get(LocalCache.java:4147) [error] at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4151) [error] at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5140) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$.$anonfun$buildSettings$4(ScalafmtCorePlugin.scala:234) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$.$anonfun$scalafmtCoreSettings$26(ScalafmtCorePlugin.scala:154) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:44) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:42) [error] at sbt.std.Transform$$anon$4.work(System.scala:64) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:257) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16) [error] at sbt.Execute.work(Execute.scala:266) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:257) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:167) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:32) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] java.util.concurrent.ExecutionException: java.lang.ClassNotFoundException: com.lucidchart.scalafmt.impl.ScalafmtFactory [error] at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:502) [error] at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:481) [error] at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:83) [error] at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:142) [error] at com.google.common.cache.LocalCache$LoadingValueReference.waitForValue(LocalCache.java:3755) [error] at com.google.common.cache.LocalCache$Segment.waitForLoadingValue(LocalCache.java:2319) [error] at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2306) [error] at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212) [error] at com.google.common.cache.LocalCache.get(LocalCache.java:4147) [error] at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4151) [error] at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5140) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$.$anonfun$buildSettings$4(ScalafmtCorePlugin.scala:234) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$.$anonfun$scalafmtCoreSettings$26(ScalafmtCorePlugin.scala:154) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:44) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:42) [error] at sbt.std.Transform$$anon$4.work(System.scala:64) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:257) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16) [error] at sbt.Execute.work(Execute.scala:266) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:257) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:167) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:32) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] Caused by: java.lang.ClassNotFoundException: com.lucidchart.scalafmt.impl.ScalafmtFactory [error] at java.net.URLClassLoader.findClass(URLClassLoader.java:381) [error] at com.lucidchart.sbt.scalafmt.BridgeClassLoader.findClass(BridgeClassLoader.scala:11) [error] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [error] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anon$1.load(ScalafmtCorePlugin.scala:230) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anon$1.load(ScalafmtCorePlugin.scala:227) [error] at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3708) [error] at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2416) [error] at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2299) [error] at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212) [error] at com.google.common.cache.LocalCache.get(LocalCache.java:4147) [error] at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4151) [error] at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5140) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$.$anonfun$buildSettings$4(ScalafmtCorePlugin.scala:234) [error] at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$.$anonfun$scalafmtCoreSettings$26(ScalafmtCorePlugin.scala:154) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:44) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:42) [error] at sbt.std.Transform$$anon$4.work(System.scala:64) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:257) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16) [error] at sbt.Execute.work(Execute.scala:266) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:257) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:167) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:32) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748)

etspaceman avatar Oct 07 '17 20:10 etspaceman

I'm suffering from the same issue.

swsnr avatar Nov 09 '17 12:11 swsnr

Same issue here with "com.lucidchart" % "sbt-scalafmt" % "1.15" and scalafmtVersion in ThisBuild := "1.4.0"

kimxogus avatar Jan 04 '18 09:01 kimxogus

From time to time, I am getting another ClassDefNotFound error on a multi-project with sbt-scalafmt 1.14 and scala-fmt 1.2.0:

com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2205)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:154)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:145)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$
	at org.scalafmt.config.Config$.$anonfun$fromConf$3(Config.scala:83)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.$anonfun$fromConf$1(Config.scala:68)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.fromConf(Config.scala:67)
	at org.scalafmt.config.Config$.fromHoconString(Config.scala:55)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:11)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:9)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:237)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:236)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:154)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:145)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
com.google.common.util.concurrent.ExecutionError: java.lang.OutOfMemoryError: Metaspace
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2205)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:154)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:145)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.OutOfMemoryError: Metaspace
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at com.lucidchart.sbt.scalafmt.BridgeClassLoader.findClass(BridgeClassLoader.scala:11)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at scala.meta.parsers.Parse$.parseSource$lzycompute(Parse.scala:31)
	at scala.meta.parsers.Parse$.parseSource(Parse.scala:31)
	at org.scalafmt.config.ScalafmtRunner$.<init>(ScalafmtRunner.scala:28)
	at org.scalafmt.config.ScalafmtRunner$.<clinit>(ScalafmtRunner.scala)
	at org.scalafmt.config.ScalafmtConfig$.apply$default$14(ScalafmtConfig.scala:2)
	at org.scalafmt.config.Settings.$init$(Settings.scala:17)
	at org.scalafmt.config.ScalafmtConfig$.<init>(ScalafmtConfig.scala:38)
	at org.scalafmt.config.ScalafmtConfig$.<clinit>(ScalafmtConfig.scala)
	at org.scalafmt.config.Config$.$anonfun$fromConf$3(Config.scala:83)
	at org.scalafmt.config.Config$$$Lambda$5271/873247966.apply(Unknown Source)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.$anonfun$fromConf$1(Config.scala:68)
	at org.scalafmt.config.Config$$$Lambda$5270/324642714.apply(Unknown Source)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.fromConf(Config.scala:67)
	at org.scalafmt.config.Config$.fromHoconString(Config.scala:55)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:11)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:9)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:237)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:236)
com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2205)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:154)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:145)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$
	at org.scalafmt.config.Config$.$anonfun$fromConf$3(Config.scala:83)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.$anonfun$fromConf$1(Config.scala:68)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.fromConf(Config.scala:67)
	at org.scalafmt.config.Config$.fromHoconString(Config.scala:55)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:11)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:9)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:237)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:236)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:154)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:145)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
com.google.common.util.concurrent.ExecutionError: java.lang.OutOfMemoryError: Metaspace
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2205)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:154)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:145)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.OutOfMemoryError: Metaspace
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at com.lucidchart.sbt.scalafmt.BridgeClassLoader.findClass(BridgeClassLoader.scala:11)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at scala.meta.parsers.Parse$.parseSource$lzycompute(Parse.scala:31)
	at scala.meta.parsers.Parse$.parseSource(Parse.scala:31)
	at org.scalafmt.config.ScalafmtRunner$.<init>(ScalafmtRunner.scala:28)
	at org.scalafmt.config.ScalafmtRunner$.<clinit>(ScalafmtRunner.scala)
	at org.scalafmt.config.ScalafmtConfig$.apply$default$14(ScalafmtConfig.scala:2)
	at org.scalafmt.config.Settings.$init$(Settings.scala:17)
	at org.scalafmt.config.ScalafmtConfig$.<init>(ScalafmtConfig.scala:38)
	at org.scalafmt.config.ScalafmtConfig$.<clinit>(ScalafmtConfig.scala)
	at org.scalafmt.config.Config$.$anonfun$fromConf$3(Config.scala:83)
	at org.scalafmt.config.Config$$$Lambda$5271/873247966.apply(Unknown Source)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.$anonfun$fromConf$1(Config.scala:68)
	at org.scalafmt.config.Config$$$Lambda$5270/324642714.apply(Unknown Source)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.fromConf(Config.scala:67)
	at org.scalafmt.config.Config$.fromHoconString(Config.scala:55)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:11)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:9)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:237)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:236)
com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2205)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:154)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:145)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$
	at org.scalafmt.config.Config$.$anonfun$fromConf$3(Config.scala:83)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.$anonfun$fromConf$1(Config.scala:68)
	at metaconfig.Configured.flatMap(Configured.scala:29)
	at org.scalafmt.config.Config$.fromConf(Config.scala:67)
	at org.scalafmt.config.Config$.fromHoconString(Config.scala:55)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:11)
	at com.lucidchart.scalafmt.impl.ScalafmtFactory.fromConfig(ScalafmtFactory.scala:9)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:237)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anon$2.load(ScalafmtCorePlugin.scala:236)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$$anonfun$30$$anon$1$$anonfun$load$1.apply(ScalafmtCorePlugin.scala:239)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:154)
	at com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin$autoImport$$anonfun$19.apply(ScalafmtCorePlugin.scala:145)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
[error] (trip-booking/sbt:scalafmt::scalafmtter) com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$
[error] (test-lib/sbt:scalafmt::scalafmtter) com.google.common.util.concurrent.ExecutionError: java.lang.OutOfMemoryError: Metaspace
[error] (core/sbt:scalafmt::scalafmtter) com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$
[error] (common/sbt:scalafmt::scalafmtter) com.google.common.util.concurrent.ExecutionError: java.lang.OutOfMemoryError: Metaspace
[error] (api/sbt:scalafmt::scalafmtter) com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Could not initialize class org.scalafmt.config.ScalafmtConfig$

markusjura avatar Jan 05 '18 09:01 markusjura

Also experiencing this problem in a multi-project build

dhoepelman avatar Mar 16 '18 12:03 dhoepelman

Same problem with 1.15 as soon as I add

scalafmtOnCompile in ThisBuild := true

Sebruck avatar Jul 05 '18 13:07 Sebruck

Same here. Error still persists.

  • sbt 1.2.3
  • scalafmt 1.15
  • project matrix 0.1.0

muuki88 avatar Dec 05 '18 14:12 muuki88

I ran into the same issue. In my case, the cause was libraryDependencies := instead of libraryDependencies ++=. Hope it may help some of you 😉

avandendaele avatar Apr 17 '19 11:04 avandendaele

I had this issue on a single project build. Eventually found out, that it was caused by coursier plugin.

It's not an issue with sbt-scalafmt, but web search leads to this thread, so (hopefully) this comment may save someone an hour of struggle with build.sbt

koiuo avatar Jun 12 '19 21:06 koiuo