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
Comments
Thanks for the report! I don't think I've seen this. Does this happen only with Play? |
@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. |
You can type in |
https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html
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? |
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
|
You are using Scala 3.4.1, can you try Scala 3.3.3? |
I tried switching to 3.3.3 but now the exception even throws when running Output
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 |
If you type |
No, there aren't any true/false keys. Output
|
What's |
I don't know what it is or where it's coming from. Running I checked if it was set as a cmdline parameter using |
Do you have |
This is an existing project created more than 10 years ago. We are permanently evolve with language and build tools. Its a long journey.
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.
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. |
Same issue started happening for me when Play reloads. Environment is as follows:
|
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.
I'll try to find some time to do this and report back. |
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. |
Another update. Today upgraded project: Project works fine. But after some time after page reload got the error again: Stack trace from Play page
Stack trace from SBT console:
As before, after |
It's a bit hard to tell what's going on here without a reproducer project...
|
|
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. |
It seems you all use JDK 17? Am I right? |
@DevNico How did you com up with |
Because one of the last entries in the stack trace was the Should've provided those details from the start sorry about that. |
@saaivs Actually, what do you mean with
like where do you set which scala version? |
And everyone here is using Play? Absolutely everyone? Just to make sure this is related to Play... |
My guess is this has nothing to do with any IMHO the above hack only makes sure that a @DevNico I would now focus on
because they all have boolean "values", for sharing we don't know. Who sets this keys? |
@DevNico Actually, you reference the wrong file here, one from Scala 2.13. But the stacktrace from your above's comment where you see I think we got confused and thought it's about they key, but IMHO it's about the value. |
@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... |
@mkurz yeah sure, I've joined the discord and sent you a friend request. |
I think best is to first find out which property is causing this problem (like which one is of type 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
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 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 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 (
and then run your application and make it fail again and post your output. |
@saaivs @costas80 @art-ws @DevNico Please help and follow the steps of my comment above, thanks! |
@mkurz, I tried to follow your steps but when running ...
... I get ...
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 |
@costas80 Are you using flyway? If yes, which version? |
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:
So is was causing the 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)
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. |
@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). |
Not sure if it's worth it. For me this issue is done. @eed3si9n You can close this ticket, thanks! |
Steps
sbt
(multi-project)project [PROJECT] ; run
- PlayFramework web application*.scala
code[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
sbt
sbt
againProblem
Environment
Stacktrace
The text was updated successfully, but these errors were encountered: