4

We are using Play framework (v2.8.16) with Pac4j (v10.0.2) as the security framework running on OpenJDK 12. Our application is a Java app and we are using Play's multi-module setup. In Play's development mode there is a hot code reloading feature that seems to get hickups on custom classes that extend Pac4j types. This happens to some developers very frequently and to other only every once in a few days (same JDK & libraries). Running from IDE (IntelliJ) or command line SBT is the same.

So given a custom type:

public class CustomJwtProfile extends org.pac4j.jwt.profile.JwtProfile

The hot code reload fails with:

play.api.PlayException: Execution exception[[ClassCastException: class my.package.CustomJwtProfile cannot be cast to class class my.package.CustomJwtProfile (class my.package.CustomJwtProfile is in unnamed module of loader 
play.runsupport.DelegatedResourcesClassLoader @2a1321ec; my.package.CustomJwtProfile is in unnamed module of loader 
play.runsupport.DelegatedResourcesClassLoader @47424930)]]

I suspect Play's code reloading works via a quite coarse grained mechanism, that just reloads the whole application in a different class-loader (We see on code reloading log output that initializes/bootstraps the Play app again). The above errors seems to me like a mismatch of runtime-types, so the same "class-file type" is present in different class loaders - so in JVM reality they form two different runtime-types and that causes the ClassCastExcpeption. Maybe the Pac4j code is not swapped out correctly together with the application code and some objects of the old runtime-type remain ?

We currently just stop the Play process and start it via SBT again .. that slows the heavily affected developers down quite alot and effectivly makes the hot code reloading useless.

Thanks for any ideas ...

Ruwanka De Silva
  • 3,555
  • 6
  • 35
  • 51
jdo
  • 71
  • 5

0 Answers0