Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"java.lang.Boolean cannot be cast to class java.lang.String" on Play's run task #7542

Closed
saaivs opened this issue Apr 8, 2024 · 37 comments
Closed

Comments

@saaivs
Copy link

saaivs commented Apr 8, 2024

Steps

  1. Open project in sbt (multi-project)
  2. Run project [PROJECT] ; run - PlayFramework web application
  3. Observe application working as expected
  4. Change the any source *.scala code
  5. Reload web page
  6. Observe the error [error] ([PROJECT] / Compile / compileIncremental) java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')

Workaround

  1. Exit from sbt
  2. Start sbt again
  3. Start application again
  4. Observe application working as expected and next code changes not fails

Problem

  1. Behavior looks like a bug

Environment

  1. Java 17.0.8.1
  2. sbt 1.9.9
  3. Scala2 2.13.13 (for PlayFramework)
  4. Scala3 3.3.1 (for SBT)
  5. Play 3.0.2

Stacktrace


->java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
     scala.collection.convert.Wrappers$JPropertiesWrapper$$anon$6.next(Wrappers.scala:444)
     scala.collection.convert.Wrappers$JPropertiesWrapper$$anon$6.next(Wrappers.scala:439)
     scala.collection.TraversableOnce.collectFirst(TraversableOnce.scala:180)
     scala.collection.TraversableOnce.collectFirst$(TraversableOnce.scala:167)
     scala.collection.AbstractIterator.collectFirst(Iterator.scala:1431)
     sbt.internal.inc.CompilerArguments.findBoot$1(CompilerArguments.scala:108)
     sbt.internal.inc.CompilerArguments.$anonfun$createBootClasspath$2(CompilerArguments.scala:113)
     scala.Option.getOrElse(Option.scala:189)
     sbt.internal.inc.CompilerArguments.createBootClasspath(CompilerArguments.scala:113)
     sbt.internal.inc.CompilerArguments.bootClasspath(CompilerArguments.scala:134)
     sbt.internal.inc.CompilerArguments.bootClasspathFor(CompilerArguments.scala:137)
     sbt.internal.inc.MixedAnalyzingCompiler$.withBootclasspath(MixedAnalyzingCompiler.scala:460)
     sbt.internal.inc.MixedAnalyzingCompiler$.searchClasspathAndLookup(MixedAnalyzingCompiler.scala:422)
     sbt.internal.inc.MixedAnalyzingCompiler$.searchClasspathAndLookup(MixedAnalyzingCompiler.scala:401)
     sbt.internal.inc.MixedAnalyzingCompiler$.apply(MixedAnalyzingCompiler.scala:435)
     sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
     sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
     sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
     sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
     sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2371)
     sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2321)
     sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31)
     sbt.internal.io.Retry$.apply(Retry.scala:47)
     sbt.internal.io.Retry$.apply(Retry.scala:29)
     sbt.internal.io.Retry$.apply(Retry.scala:24)
     sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
     sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2319)
     scala.Function1.$anonfun$compose$1(Function1.scala:49)
     sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
     sbt.std.Transform$$anon$4.work(Transform.scala:69)
     sbt.Execute.$anonfun$submit$2(Execute.scala:283)
     sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
     sbt.Execute.work(Execute.scala:292)
     sbt.Execute.$anonfun$submit$1(Execute.scala:283)
     sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
     sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
     java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
     java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
     java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
     java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
     java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
     java.base/java.lang.Thread.run(Thread.java:833)
@eed3si9n eed3si9n transferred this issue from sbt/website Apr 17, 2024
@eed3si9n
Copy link
Member

Thanks for the report! I don't think I've seen this. Does this happen only with Play?
@mkurz Do you know what's happening here?

@DevNico
Copy link

DevNico commented Apr 18, 2024

@eed3si9n are there maybe some commandline options or anything for more verbose logging? I'd be happy to provide every help I can to fix this issue.

@eed3si9n
Copy link
Member

You can type in debug in the sbt shell first to see debug logs.
Also could you try with sbt 1.10.0-RC2 please?

@eed3si9n
Copy link
Member

https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html

Similarly, the call to the propertyNames or list method will fail if it is called on a "compromised" Properties object that contains a non-String key.

I wonder if system properties are "compromised", not in security sense, but type safety-wise, since it indicates that your sys props contains a boolean key?

@eed3si9n eed3si9n changed the title [error] ([PROJECT] / Compile / compileIncremental) java.lang.ClassCastException "java.lang.Boolean cannot be cast to class java.lang.String" on Play's run task Apr 19, 2024
@DevNico
Copy link

DevNico commented Apr 19, 2024

I reproduced the issue with sbt 1.10.0-RC2. I also ran debug but the additional output doesn't seem all that useful.

I had to redact some paths / class names due to this happening in a proprietary code base.

Output
[root] $ test
[debug] Other repositories:
[debug] Copy resource mappings:
[debug] 	(/project-path/test/resources/logback.xml,/project-path/target/scala-3.4.1/test-classes/logback.xml)
[debug] Default repositories:
[debug] Using inline dependencies specified in Scala.
[debug] Other repositories:
[debug] Default repositories:
[debug] Using inline dependencies specified in Scala.
[debug] Copy resource mappings:
[debug] 	
[debug] Copy resource mappings:
[debug] 	(/project-path/conf/logback.xml,/project-path/target/scala-3.4.1/classes/logback.xml)
[debug] 	(/project-path/conf/application-local.conf,/project-path/target/scala-3.4.1/classes/application-local.conf)
[debug] 	(/project-path/conf/application.conf,/project-path/target/scala-3.4.1/classes/application.conf)
[debug] 	(/project-path/conf/routes,/project-path/target/scala-3.4.1/classes/routes)
[debug] 	(/project-path/conf/db/migration/V008__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V008__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V003__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V003__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V011__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V011__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V006__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V006__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V002__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V002__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V007__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V007__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V010__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V010__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V005__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V005__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V004__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V004__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V012__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V012__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V001__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V001__REMOVED.sql)
[debug] 	(/project-path/conf/db/migration/V009__REMOVED.sql,/project-path/target/scala-3.4.1/classes/db/migration/V009__REMOVED.sql)
[debug] [zinc] IncrementalCompile -----------
[debug] IncrementalCompile.incrementalCompile
[debug] previous = Stamps for: 8 products, 1 sources, 4 libraries
[debug] current source = Set(${BASE}/modules/slick/src/main/scala/DatabaseCodegen.scala)
[debug] > initialChanges = InitialChanges(Changes(added = Set(), removed = Set(), changed = Set(), unmodified = ...),Set(),Set(),API Changes: Set())
[debug] No changes
[debug] Created transactional ClassFileManager with tempDir = /project-path/modules/slick/target/scala-3.4.1/classes.bak
[debug] Removing the temporary directory used for backing up class files: /project-path/modules/slick/target/scala-3.4.1/classes.bak
[debug] Copy resource mappings:
[debug] 	(/project-path/modules/api/target/scala-3.4.1/resource_managed/main/META-INF/smithy/REMOVED.smithy,/project-path/modules/api/target/scala-3.4.1/classes/META-INF/smithy/REMOVED.smithy)
// List of resources shortened for brevity
[debug] [zinc] IncrementalCompile -----------
[debug] IncrementalCompile.incrementalCompile
[debug] previous = Stamps for: 996 products, 317 sources, 2 libraries
[debug] current source = Set(${BASE}/modules/api/target/scala-3.4.1/src_managed/main/scala/project/api/SomeOutput.scala)
// Above Set shortened for brevity
[debug] > initialChanges = InitialChanges(Changes(added = Set(), removed = Set(), changed = Set(), unmodified = ...),Set(),Set(),API Changes: Set())
[debug] No changes
[debug] Created transactional ClassFileManager with tempDir = /project-path/modules/api/target/scala-3.4.1/classes.bak
[debug] Removing the temporary directory used for backing up class files: /project-path/modules/api/target/scala-3.4.1/classes.bak
[debug] [zinc] IncrementalCompile -----------
[debug] IncrementalCompile.incrementalCompile
[debug] previous = Stamps for: 1184 products, 250 sources, 55 libraries
[debug] current source = Set()
// Above Set shortened for brevity
[debug] > initialChanges = InitialChanges(Changes(added = Set(), removed = Set(), changed = Set(), unmodified = ...),Set(),Set(),API Changes: Set())
[debug] No changes
[debug] Created transactional ClassFileManager with tempDir = /project-path/target/scala-3.4.1/classes.bak
[debug] Removing the temporary directory used for backing up class files: /project-path/target/scala-3.4.1/classes.bak
[debug] [zinc] IncrementalCompile -----------
[debug] IncrementalCompile.incrementalCompile
[debug] previous = Stamps for: 355 products, 18 sources, 34 libraries
[debug] current source = Set()
// Above Set shortened for brevity
[debug] > initialChanges = InitialChanges(Changes(added = Set(), removed = Set(), changed = Set(), unmodified = ...),Set(),Set(),API Changes: Set())
// Above Set "added" shortened for brevity
[debug]
[debug] Initial source changes:
[debug] 	removed: Set()
[debug] 	added: Set()
[debug] 	modified: Set()
// Above Set shortened for brevity
[debug] Invalidated products: Set()
[debug] External API changes: API Changes: Set()
[debug] Modified binary dependencies: Set()
[debug] Initial directly invalidated classes: Set(controller.SomeControllerSpec)
[debug] Sources indirectly invalidated by:
[debug] 	product: Set()
[debug] 	binary dep: Set()
[debug] 	external source: Set()
[debug] All initially invalidated classes: Set(controller.SomeControllerSpec)
[debug] All initially invalidated sources:Set()
// Above Set shortened for brevity
[debug] Created transactional ClassFileManager with tempDir = /project-path/target/scala-3.4.1/test-classes.bak
[debug] Initial set of included nodes: controller.SomeControllerSpec
[debug] About to delete class files:
[debug] 	SomeControllerSpec$$anon$1.class
[debug] 	SomeControllerSpec$$anon$2.class
[debug] 	SomeControllerSpec.class
[debug] 	SomeControllerSpec$$anon$1.tasty
[debug] 	SomeControllerSpec$$anon$2.tasty
[debug] 	SomeControllerSpec.tasty
[debug] We backup class files:
[debug] 	SomeControllerSpec$$anon$1.class
[debug] 	SomeControllerSpec$$anon$2.class
[debug] 	SomeControllerSpec.class
[debug] 	SomeControllerSpec$$anon$1.tasty
[debug] 	SomeControllerSpec$$anon$2.tasty
[debug] 	SomeControllerSpec.tasty
[debug] compilation cycle 1
[info] compiling 1 Scala source to /project-path/target/scala-3.4.1/test-classes ...
[debug] Returning already retrieved and compiled bridge: /Users/devnico/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-sbt-bridge/3.4.1/scala3-sbt-bridge-3.4.1.jar.
[debug] [zinc] Running cached compiler 97964d5 for Scala Compiler version 3.4.1
[debug] Rolling back changes to class files.
[debug] Removing generated classes:
[debug] Restoring class files:
[debug] 	SomeControllerSpec.tasty
[debug] 	SomeControllerSpec$$anon$1.class
[debug] 	SomeControllerSpec.class
[debug] 	SomeControllerSpec$$anon$2.class
[debug] Removing the temporary directory used for backing up class files: /project-path/target/scala-3.4.1/test-classes.bak
[error] ## Exception when compiling 18 sources to /project-path/target/scala-3.4.1/test-classes
[error] java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
[error] scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:623)
[error] scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:618)
[error] scala.collection.IterableOnceOps.find(IterableOnce.scala:634)
[error] scala.collection.IterableOnceOps.find$(IterableOnce.scala:631)
[error] scala.collection.AbstractIterator.find(Iterator.scala:1300)
[error] dotty.tools.dotc.config.PathResolver$Environment$.searchForBootClasspath(PathResolver.scala:40)
[error] dotty.tools.dotc.config.PathResolver$Environment$.javaBootClassPath(PathResolver.scala:49)
[error] dotty.tools.dotc.config.PathResolver$Defaults$.javaBootClassPath(PathResolver.scala:75)
[error] dotty.tools.dotc.config.CommonScalaSettings.$init$(ScalaSettings.scala:100)
[error] dotty.tools.dotc.config.ScalaSettings.<init>(ScalaSettings.scala:18)
[error] dotty.tools.dotc.core.Contexts$ContextBase.<init>(Contexts.scala:865)
[error] dotty.tools.dotc.Driver.initCtx(Driver.scala:60)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:125)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:194)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:249)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:184)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:164)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:164)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:212)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3(Incremental.scala:178)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3$adapted(Incremental.scala:176)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:454)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:117)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:265)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:409)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:496)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:396)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:170)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2423)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2373)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:41)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:41)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2371)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error] java.base/java.lang.Thread.run(Thread.java:1583)
[error]
[error] stack trace is suppressed; run last Test / compileIncremental for the full output
[error] (Test / compileIncremental) java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
[error] Total time: 0 s, completed 19 Apr 2024, 18:30:22
[root] $

@mkurz
Copy link
Member

mkurz commented Apr 19, 2024

You are using Scala 3.4.1, can you try Scala 3.3.3?

@DevNico
Copy link

DevNico commented Apr 19, 2024

I tried switching to 3.3.3 but now the exception even throws when running reload.

Output
[info] welcome to sbt 1.10.0-RC2 (Amazon.com Inc. Java 21.0.2)
[info] loading settings for project root-build from plugins.sbt ...
[info] loading project definition from /project-path/project
[debug] not up to date. inChanged = true, force = false
[debug] Updating ProjectRef(uri("file:/project-path/project/"), "root-build")...
[debug] Done updating ProjectRef(uri("file:/project-path/project/"), "root-build")
[error] ## Exception when compiling 0 sources to /project-path/project/target/scala-2.12/sbt-1.0/classes
[error] java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
[error] scala.collection.convert.Wrappers$JPropertiesWrapper$$anon$6.next(Wrappers.scala:444)
[error] scala.collection.convert.Wrappers$JPropertiesWrapper$$anon$6.next(Wrappers.scala:439)
[error] scala.collection.TraversableOnce.collectFirst(TraversableOnce.scala:180)
[error] scala.collection.TraversableOnce.collectFirst$(TraversableOnce.scala:167)
[error] scala.collection.AbstractIterator.collectFirst(Iterator.scala:1431)
[error] sbt.internal.inc.CompilerArguments.findBoot$1(CompilerArguments.scala:108)
[error] sbt.internal.inc.CompilerArguments.$anonfun$createBootClasspath$2(CompilerArguments.scala:113)
[error] scala.Option.getOrElse(Option.scala:189)
[error] sbt.internal.inc.CompilerArguments.createBootClasspath(CompilerArguments.scala:113)
[error] sbt.internal.inc.CompilerArguments.bootClasspath(CompilerArguments.scala:134)
[error] sbt.internal.inc.CompilerArguments.bootClasspathFor(CompilerArguments.scala:137)
[error] sbt.internal.inc.MixedAnalyzingCompiler$.withBootclasspath(MixedAnalyzingCompiler.scala:461)
[error] sbt.internal.inc.MixedAnalyzingCompiler$.searchClasspathAndLookup(MixedAnalyzingCompiler.scala:423)
[error] sbt.internal.inc.MixedAnalyzingCompiler$.searchClasspathAndLookup(MixedAnalyzingCompiler.scala:402)
[error] sbt.internal.inc.MixedAnalyzingCompiler$.apply(MixedAnalyzingCompiler.scala:436)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2423)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2373)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:41)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:41)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2371)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error] java.base/java.lang.Thread.run(Thread.java:1583)
[error]
[error] stack trace is suppressed; run last Compile / compileIncremental for the full output
[error] (Compile / compileIncremental) java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')

I then deleted all target dirs and restarted sbt shell. That made it work again and I was able to compile and run the tests. Changed some code and recompiled which also worked. Then I tried running reload again which resulted in the same exception as in the above Output (the first one).

@eed3si9n
Copy link
Member

If you type eval sys.props on the shell, do you see anything weird, like true or false in the key?

@DevNico
Copy link

DevNico commented Apr 20, 2024

No, there aren't any true/false keys.

Output
[info] ans: scala.sys.SystemProperties = Map(
java.specification.version -> 21,
sun.jnu.encoding -> UTF-8,
java.class.path -> /Users/devnico/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.10.0-RC2/sbt-launch-1.10.0-RC2.jar:/Users/devnico/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/get-coursier/sbt/sbt-runner/0.2.0/sbt-runner-0.2.0.jar,
java.vm.vendor -> Amazon.com Inc.,
sun.arch.data.model -> 64,
jline.shutdownhook -> false,
java.vendor.url -> https://aws.amazon.com/corretto/,
user.timezone -> Europe/Berlin,
java.vm.specification.version -> 21,
os.name -> Mac OS X,
sun.java.launcher -> SUN_STANDARD,
user.country -> DE,
sun.boot.library.path -> /Users/devnico/.sdkman/candidates/java/21.0.2-amzn/lib,
sun.java.command -> xsbt.boot.Boot,
jdk.debug -> release,
sun.cpu.endian -> little,
user.home -> /Users/devnico,
user.language -> en,
java.specification.vendor -> Oracle Corporation,
sbt.ipcsocket.tmpdir -> /var/folders/c0/d22dqjx96y36q8nnwz3vtvv00000gn/T/.sbt78078e55/ipcsocket,
swoval.tmpdir -> /var/folders/c0/d22dqjx96y36q8nnwz3vtvv00000gn/T/.sbt78078e55/swoval,
java.version.date -> 2024-01-16,
java.home -> /Users/devnico/.sdkman/candidates/java/21.0.2-amzn,
file.separator -> /,
java.vm.compressedOopsMode -> Zero based,
line.separator ->,
java.vm.specification.vendor -> Oracle Corporation,
java.specification.name -> Java Platform API Specification,
apple.awt.application.name -> Boot,
jline.esc.timeout -> 0,
sun.management.compiler -> HotSpot 64-Bit Tiered Compilers,
java.runtime.version -> 21.0.2+13-LTS,
user.name -> devnico,
stdout.encoding -> UTF-8,
path.separator -> :,
jna.nosys -> true,
os.version -> 14.5,
java.runtime.name -> OpenJDK Runtime Environment,
log4j.ignoreTCL -> true,
file.encoding -> UTF-8,
java.vm.name -> OpenJDK 64-Bit Server VM,
java.vendor.version -> Corretto-21.0.2.13.1,
sbt-launch.version -> 1.10.0-RC2,
java.vendor.url.bug -> https://github.com/corretto/corretto-21/issues/,
java.io.tmpdir -> /var/folders/c0/d22dqjx96y36q8nnwz3vtvv00000gn/T/,
java.version -> 21.0.2,
user.dir -> /Users/devnico/project-path,
os.arch -> aarch64,
java.vm.specification.name -> Java Virtual Machine Specification,
native.encoding -> UTF-8,
java.library.path -> /Users/devnico/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.,
java.vm.info -> mixed mode,
sharing,
stderr.encoding -> UTF-8,
java.vendor -> Amazon.com Inc.,
java.vm.version -> 21.0.2+13-LTS,
sun.io.unicode.encoding -> UnicodeBig,
java.class.version -> 65.0
)

@eed3si9n
Copy link
Member

What's sharing,? That looks a bit odd without the key entry and/or value entry.

@DevNico
Copy link

DevNico commented Apr 20, 2024

I don't know what it is or where it's coming from.

Running eval System.getProperty("sharing") prints [INFO] ans: String = null

I checked if it was set as a cmdline parameter using ps aux | grep java but couldn't find it there either.

@mkurz
Copy link
Member

mkurz commented Apr 22, 2024

Do you have scalacOptions and/or javacOptions defined in build.sbt (or in a .scala file in the project/ folder?
Also is this a fresh project or an existing one? When did the problem start to appear? Can you roll back to project to a git commit so it works?

@saaivs
Copy link
Author

saaivs commented Apr 22, 2024

Do you have scalacOptions and/or javacOptions defined in build.sbt (or in a .scala file in the project/ folder?


ThisBuild / scalaVersion := Dependencies.Versions.scala3 // "3.3.1" 

lazy val sharedScalacOptions =
  Seq("-encoding", "UTF-8", "-Wunused:imports,privates,locals")

ThisBuild / scalacOptions ++= sharedScalacOptions ++ {
  CrossVersion.partialVersion(scalaVersion.value) match {
    case Some((3, _)) => Seq("-Ykind-projector", "-Ykind-projector:underscores")
    case default => Seq("-Xsource:3", "-Xfuture", "-feature", "-explaintypes", 
    "-Ywarn-unused:imports", "-Xlint:adapted-args", "-deprecation")
  }
}  

Also is this a fresh project or an existing one?

This is an existing project created more than 10 years ago. We are permanently evolve with language and build tools. Its a long journey.

When did the problem start to appear?

Probably after the upgrade to SBT close to v1.8.0 (not sure). With sbt v1.7 everything was fine, as far as remember. No less than a year was simpler just workaround a problem with restart and hope it will dissapear someday itself as it appeared.

Can you roll back to project to a git commit so it works?

I will try to isolate the breaking change in git history. Can't promise do it soon, but will try do my best. Will keep you posted.

@costas80
Copy link

Same issue started happening for me when Play reloads. Environment is as follows:

  • Java: 17.0.6
  • sbt: 1.9.8
  • Scala: 2.13.12
  • Play: 3.0.1

@mkurz
Copy link
Member

mkurz commented Apr 29, 2024

Same issue started happening for me when Play reloads. Environment is as follows:

* Java: 17.0.6

* sbt: 1.9.8

* Scala: 2.13.12

* Play: 3.0.1

Did you start a new Play project or did you upgrade to those versions in an existing one? Which versions did you use before?
Maybe we can track it down if you start to downgrade one by one, like sbt 1.9.8 to 1.9.7, etc.

@costas80
Copy link

Did you start a new Play project or did you upgrade to those versions in an existing one? Which versions did you use before?

I can't be certain I'm afraid... It could be the upgrade from Play 3.0.0 to 3.0.1. Otherwise for SBT we last migrated from 1.6.2 to 1.9.8 but that was several months ago.

Maybe we can track it down if you start to downgrade one by one, like sbt 1.9.8 to 1.9.7, etc.

I'll try to find some time to do this and report back.

@saaivs
Copy link
Author

saaivs commented May 7, 2024

I will try to isolate the breaking change in git history.

Some update. Strange story. I tried to downgrade to the previous brunch and didn't get luck to find out the breaking change. More - currently I can't reproduce the issue at all! It's dissapeard after the issue report.

Assumptions: Propably it somehow related the JVM installation. Probably it was "broken". I have 2 installations locally: Java 1.8 and Java 17. For different sbt verisons I did switch between them.

Will keep eyes opened and keep you posted.

@saaivs
Copy link
Author

saaivs commented May 8, 2024

Another update.

Today upgraded project:
SBT: 1.10.0
Scala2: 2.13.14
Scala3: 3.4.1
Java: 17.0.8.1
Play: 3.0.3

Project works fine. But after some time after page reload got the error again:

Stack trace from Play page

java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
     scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:623)
     scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:618)
     scala.collection.IterableOnceOps.find(IterableOnce.scala:634)
     scala.collection.IterableOnceOps.find$(IterableOnce.scala:631)
     scala.collection.AbstractIterator.find(Iterator.scala:1300)
     dotty.tools.dotc.config.PathResolver$Environment$.searchForBootClasspath(PathResolver.scala:40)
     dotty.tools.dotc.config.PathResolver$Environment$.javaBootClassPath(PathResolver.scala:49)
     dotty.tools.dotc.config.PathResolver$Defaults$.javaBootClassPath(PathResolver.scala:75)
     dotty.tools.dotc.config.CommonScalaSettings.$init$(ScalaSettings.scala:100)
     dotty.tools.dotc.config.ScalaSettings.<init>(ScalaSettings.scala:18)
     dotty.tools.dotc.core.Contexts$ContextBase.<init>(Contexts.scala:865)
     dotty.tools.dotc.Driver.initCtx(Driver.scala:60)
     dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:125)
     dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
     sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
     sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:194)
     scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
     sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:249)
     sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:184)
     sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:164)
     sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
     sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:164)
     sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:212)
     sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
     sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
     sbt.internal.inc.Incremental$.$anonfun$apply$3(Incremental.scala:178)
     sbt.internal.inc.Incremental$.$anonfun$apply$3$adapted(Incremental.scala:176)
     sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:454)
     sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:117)
     sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
     sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
     sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:265)
     sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:409)
     sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:496)
     sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:396)
     sbt.internal.inc.Incremental$.apply(Incremental.scala:170)
     sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
     sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
     sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
     sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
     sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
     sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2427)
     sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2377)
     sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:41)
     sbt.internal.io.Retry$.apply(Retry.scala:47)
     sbt.internal.io.Retry$.apply(Retry.scala:29)
     sbt.internal.io.Retry$.apply(Retry.scala:24)
     sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:41)
     sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2375)
     scala.Function1.$anonfun$compose$1(Function1.scala:49)
     sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
     sbt.std.Transform$$anon$4.work(Transform.scala:69)
     sbt.Execute.$anonfun$submit$2(Execute.scala:283)
     sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
     sbt.Execute.work(Execute.scala:292)
     sbt.Execute.$anonfun$submit$1(Execute.scala:283)
     sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
     sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
     java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
     java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
     java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
     java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
     java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
     java.base/java.lang.Thread.run(Thread.java:833)

Stack trace from SBT console:

[error] ## Exception when compiling 789 sources to /opt/art/p/art-ws/scala/isportevent.com/target/scala-3.4.1/classes
[error] java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
[error] scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:623)
[error] scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:618)
[error] scala.collection.IterableOnceOps.find(IterableOnce.scala:634)
[error] scala.collection.IterableOnceOps.find$(IterableOnce.scala:631)
[error] scala.collection.AbstractIterator.find(Iterator.scala:1300)
[error] dotty.tools.dotc.config.PathResolver$Environment$.searchForBootClasspath(PathResolver.scala:40)
[error] dotty.tools.dotc.config.PathResolver$Environment$.javaBootClassPath(PathResolver.scala:49)
[error] dotty.tools.dotc.config.PathResolver$Defaults$.javaBootClassPath(PathResolver.scala:75)
[error] dotty.tools.dotc.config.CommonScalaSettings.$init$(ScalaSettings.scala:100)
[error] dotty.tools.dotc.config.ScalaSettings.<init>(ScalaSettings.scala:18)
[error] dotty.tools.dotc.core.Contexts$ContextBase.<init>(Contexts.scala:865)
[error] dotty.tools.dotc.Driver.initCtx(Driver.scala:60)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:125)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:194)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:249)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:184)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:164)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:164)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:212)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3(Incremental.scala:178)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3$adapted(Incremental.scala:176)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:454)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:117)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:265)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:409)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:496)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:396)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:170)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2427)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2377)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:41)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:41)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2375)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] java.base/java.lang.Thread.run(Thread.java:833)
[error]            
[error] stack trace is suppressed; run last Compile / compileIncremental for the full output
[error] (Compile / compileIncremental) java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
[error] play.api.http.DevHttpErrorHandler - 

! @85e48h8f8 - Internal server error, for (GET) [/] ->
 
play.sbt.PlayExceptions$UnexpectedException: Unexpected exception[ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')]
	at play.sbt.run.PlayReload$.$anonfun$taskFailureHandler$8(PlayReload.scala:121)
	at scala.Option.map(Option.scala:230)
	at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:92)
	at play.sbt.run.PlayReload$.$anonfun$compile$3(PlayReload.scala:144)
	at scala.util.Either$LeftProjection.map(Either.scala:573)
	at play.sbt.run.PlayReload$.compile(PlayReload.scala:144)
	at sbt.PlayRun$.$anonfun$playRunTask$5(PlayRun.scala:99)
	at play.runsupport.Reloader.$anonfun$reload$1(Reloader.scala:495)
	at play.runsupport.Reloader$$anon$1.run(Reloader.scala:58)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
Caused by: java.lang.ClassCastException: class java.lang.Boolean cannot be cast to class java.lang.String (java.lang.Boolean and java.lang.String are in module java.base of loader 'bootstrap')
	at scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:623)
	at scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:618)
	at scala.collection.IterableOnceOps.find(IterableOnce.scala:634)
	at scala.collection.IterableOnceOps.find$(IterableOnce.scala:631)
	at scala.collection.AbstractIterator.find(Iterator.scala:1300)
	at dotty.tools.dotc.config.PathResolver$Environment$.searchForBootClasspath(PathResolver.scala:40)
	at dotty.tools.dotc.config.PathResolver$Environment$.javaBootClassPath(PathResolver.scala:49)
	at dotty.tools.dotc.config.PathResolver$Defaults$.javaBootClassPath(PathResolver.scala:75)
	at dotty.tools.dotc.config.CommonScalaSettings.$init$(ScalaSettings.scala:100)
	at dotty.tools.dotc.config.ScalaSettings.<init>(ScalaSettings.scala:18)

As before, after sbt restart error fixed.

@mkurz
Copy link
Member

mkurz commented May 8, 2024

It's a bit hard to tell what's going on here without a reproducer project...
Can you guys please:

  1. Post on which OS this problem occurs? (macOS, Windows, Linux)
  2. Which Java distribution you are using? OpenJdk, Amazon Corretto, etc.)
  3. Which Java version you are using? (11, 17, 21, etc.)
  4. In best case, provide a project which reproduces the problem?
  5. If 4 is not possible I think you have to try to debug yourself which sys property key is causing this problem:
    If you are using IntelliJ add a "Remote JVM Debug" configuration and in the UI enter 9999 as port.
    Then, again in IntelliJ, enable "Java Exception breakpoints" (can be found in "View Breaktpoints...")
    Now start sbt with debugging enabled, e.g. on port 9999: sbt -jvm-debug 9999 shell
    Then (after sbt started), start the debug config and let's hope the debugger kicks in when the exception occurs...

@art-ws
Copy link

art-ws commented May 14, 2024

  1. Ubuntu 20.04.4 LTS
  2. openjdk 17.0.8.1 2023-08-24 , OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu120.04) , OpenJDK 64-Bit Server VM (build 17.0.8.1+1-Ubuntu-0ubuntu120.04, mixed mode, sharing)
  3. Java 17
  4. Too complex :(
  5. Will try ... Will keep you posted

@DevNico
Copy link

DevNico commented May 14, 2024

I've added the following to my build.sbt:

Global / onLoad := {
  System.setProperty(".boot.class.path", "")
  (Global / onLoad).value
}

Since adding that I've not had any more issues but I am unsure of potential negative consequences.

@mkurz
Copy link
Member

mkurz commented May 15, 2024

It seems you all use JDK 17? Am I right?
If so please let's all upgrade to the latest JDK 17.0.11+9 (this one is the latest one available in sdkman currently).
Let's please do this to avoid that this is caused by a bug in the JDK. I see that some of you use 17.0.8 and others 17.0.6...
Can you try and let me know if the problem still occurs?

@mkurz
Copy link
Member

mkurz commented May 15, 2024

@DevNico How did you com up with .boot.class.path? For me this does not make any sense.

@DevNico
Copy link

DevNico commented May 15, 2024

Because one of the last entries in the stack trace was the searchForBootClasspath method in the PathResolver I just tried to fulfill the condition in there. See: https://github.com/scala/scala/blob/ab41073758319f2c3fb37519745c9f0485017297/src/compiler/scala/tools/util/PathResolver.scala#L67 since it defaults to empty string if sun.boot.class.path isn't found I thought it to be safe to just provide a matching property with "" manually and as I said no issue since then. It's been like this for close to two weeks and usually I had the problem about once per day. But I agree with you it doesn't make any sense.

Should've provided those details from the start sorry about that.

@mkurz
Copy link
Member

mkurz commented May 15, 2024

@saaivs Actually, what do you mean with

  1. Scala2 2.13.13 (for PlayFramework)
  2. Scala3 3.3.1 (for SBT)

like where do you set which scala version?

@mkurz
Copy link
Member

mkurz commented May 15, 2024

And everyone here is using Play? Absolutely everyone? Just to make sure this is related to Play...

@mkurz
Copy link
Member

mkurz commented May 15, 2024

My guess is this has nothing to do with any *.boot.class.path* property. It's just that when looking for this property a collectFirst or find operation takes place which iterates over the elements until it comes to an element that contains a Boolean value which then can not be cast to string.
You can see that
scala.collection.convert.Wrappers$JPropertiesWrapper$$anon$6.next(Wrappers.scala:444) / scala.collection.convert.JavaCollectionWrappers$JPropertiesWrapper$$anon$6.next(JavaCollectionWrappers.scala:623) get called multiple times.

IMHO the above hack only makes sure that a .boot.class.path entry gets found before the "faulty" entry gets read via .next(...) so bascially you are just lucky.
This is just theory however.

@DevNico I would now focus on

jna.nosys -> true,
jline.shutdownhook -> false,
log4j.ignoreTCL -> true,
sharing

because they all have boolean "values", for sharing we don't know.

Who sets this keys?

@mkurz
Copy link
Member

mkurz commented May 16, 2024

Because one of the last entries in the stack trace was the searchForBootClasspath method in the PathResolver I just tried to fulfill the condition in there. See: https://github.com/scala/scala/blob/ab41073758319f2c3fb37519745c9f0485017297/src/compiler/scala/tools/util/PathResolver.scala#L67 since it defaults to empty string if sun.boot.class.path isn't found I thought it to be safe to just provide a matching property with "" manually and as I said no issue since then. It's been like this for close to two weeks and usually I had the problem about once per day. But I agree with you it doesn't make any sense.

Should've provided those details from the start sorry about that.

@DevNico Actually, you reference the wrong file here, one from Scala 2.13. But the stacktrace from your above's comment where you see searchForBootClasspath is not in Scala 2.13 but in Scala 3.4.1: https://github.com/scala/scala3/blob/3.4.1/compiler/src/dotty/tools/dotc/config/PathResolver.scala#L40
This is important because here the code is using the find method:
https://github.com/scala/scala/blob/v2.13.12/src/library/scala/collection/IterableOnce.scala#L631-L638 which eventually tries to cast both the key and the value to string: https://github.com/scala/scala/blob/v2.13.12/src/library/scala/collection/convert/JavaCollectionWrappers.scala#L623

I think we got confused and thought it's about they key, but IMHO it's about the value.

@mkurz
Copy link
Member

mkurz commented May 16, 2024

@DevNico Are you availble for a real time chat? Can you join the Play discord server (https://discord.gg/g5s2vtZ4Fa)? I would love to fix this problem...

@DevNico
Copy link

DevNico commented May 16, 2024

@mkurz yeah sure, I've joined the discord and sent you a friend request.

@mkurz
Copy link
Member

mkurz commented May 16, 2024

I think best is to first find out which property is causing this problem (like which one is of type boolean).

Can you guys help out here? You need to build sbt locally, but I made it very easy, all you need is bash installed (shouldn't be a problem when you are on Linux, also I think should work on macOS, Windows I don't know).

After following steps you should see an output like

java.io.tmpdir [class java.lang.String] / /tmp [class java.lang.String]
...

for each sys property just before the exception occurs. Please post this output, thanks!

Let's start:

First we need to build a custom zinc locally
That zinc build just stupidly prints the property keys/values and their types just before the exception occurs.
You can see what I changed here: https://github.com/sbt/zinc/compare/1.9.x...mkurz:zinc:1.9.x-mkurz?expand=1

git clone git@github.com:mkurz/zinc.git
# inside repo (cd zinc):
git checkout 1.9.x-mkurz
./zinc-publish-local

Then we need to build sbt locally
That sbt build now depends on the just build custom zinc build.
You can see what I changed here: https://github.com/sbt/sbt/compare/1.9.x...mkurz:sbt:1.9.x-mkurz?expand=1

git clone git@github.com:mkurz/sbt.git
# inside repo (cd sbt):
git checkout 1.9.x-mkurz
./sbt-publish-local

Now please set in your project the custom locally build sbt (project/build.properties):

sbt.version=1.9.10-SNAPSHOT

and then run your application and make it fail again and post your output.
Thanks!

@mkurz
Copy link
Member

mkurz commented May 16, 2024

@saaivs @costas80 @art-ws @DevNico Please help and follow the steps of my comment above, thanks!

@costas80
Copy link

@mkurz, I tried to follow your steps but when running ...

git clone git@github.com:mkurz/zinc.git

... I get ...

Cloning into 'zinc'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Also, oddly enough I noticed that I can no longer reproduce the problem on my dev setup (I'm not developing daily on this project). I can't put my finger on something that has changed but I can't get the java.lang.ClassCastException when code updates are getting compiled... In any case I'll apply your steps (if we resolve the permission issue) to have ready debug info if this comes up again.

@mkurz
Copy link
Member

mkurz commented May 17, 2024

@costas80 Are you using flyway? If yes, which version?

@mkurz
Copy link
Member

mkurz commented May 17, 2024

So I think we found the problem: I guess all of you are using flyway in your projects... If so, make sure you upgrade to at least flyway 10.11.1 or newer....

Thanks to @DevNico with figured out that following system property was using an actual boolean type as value:

polyglot.engine.WarnInterpreterOnly [class java.lang.String] / false [class java.lang.Boolean]

So is was causing the ClassCastException...
Here is a link to the actual faulty line in flyway:

The faulty flyway release 10.11.0 was cut on April 3rd. Two days later, on April 5th someone reported the exact same problem with the exact same stack trace:

Three days later, on April 8th, this issue here was opened...

On April 18th flyway 10.11.1 was released with a fix: https://documentation.red-gate.com/flyway/release-notes-and-older-versions/release-notes-for-flyway-engine#ReleaseNotesforFlywayEngine-Flyway10.11.1(2024-04-18)

  • Issue 3866 set System Properties as String rather than Boolean

If you guys can confirm that you are using flyway in your project and upgrading to 10.11.1+ resolved your problems, I think we can then close this issue.

@costas80
Copy link

So I think we found the problem: I guess all of you are using flyway in your projects...

@mkurz that has to be it indeed! Going through my project's Git history I'm pretty sure we started seeing the problem when we upgraded to Flyway 10.11.0. Since then we recently upgraded to 10.12.0 which matches when we stopped seeing the issue. Cannot be 100% certain but this seems to match very well time-wise.

In any case, it would be great to avoid something in the future causing a similar problem, by having SBT print the offending property (like what your debug hack tried to do).

@mkurz
Copy link
Member

mkurz commented May 17, 2024

In any case, it would be great to avoid something in the future causing a similar problem, by having SBT print the offending property (like what your debug hack tried to do).

Not sure if it's worth it. For me this issue is done.

@eed3si9n You can close this ticket, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants