spring-projects-experimental/spring-fu

Spring Boot 3.0.0 seems to break kofu

jesperancinha opened this issue ยท 16 comments

Hi there, in my super small project, I made an update to Spring 3.0.0 and now it seems like Spring-Fu cannot find the application context correctly.

The first exception I got was:

isbn-stacks-kofu        |   .   ____          _            __ _ _
isbn-stacks-kofu        |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
isbn-stacks-kofu        | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
isbn-stacks-kofu        |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
isbn-stacks-kofu        |   '  |____| .__|_| |_|_| |_\__, | / / / /
isbn-stacks-kofu        |  =========|_|==============|___/=/_/_/_/
isbn-stacks-kofu        |  :: Spring Boot ::                (v3.0.0)
isbn-stacks-kofu        | 
isbn-stacks-kofu        | 2022-11-29T17:24:02.658Z ERROR 7 --- [           main] o.s.boot.SpringApplication               : Application run failed
isbn-stacks-kofu        | 
isbn-stacks-kofu        | java.lang.IllegalArgumentException: Could not find class [org.jesperancinha.spring.ISBNStacksKoFuReactiveLauncher$Companion__ApplicationContextInitializer]
isbn-stacks-kofu        | 	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:333) ~[spring-core-6.0.2.jar!/:6.0.2]
isbn-stacks-kofu        | 	at org.springframework.context.aot.AotApplicationContextInitializer.instantiateInitializer(AotApplicationContextInitializer.java:80) ~[spring-context-6.0.2.jar!/:6.0.2]
isbn-stacks-kofu        | 	at org.springframework.context.aot.AotApplicationContextInitializer.initialize(AotApplicationContextInitializer.java:71) ~[spring-context-6.0.2.jar!/:6.0.2]
isbn-stacks-kofu        | 	at org.springframework.context.aot.AotApplicationContextInitializer.lambda$forInitializerClasses$0(AotApplicationContextInitializer.java:61) ~[spring-context-6.0.2.jar!/:6.0.2]
isbn-stacks-kofu        | 	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:603) ~[spring-boot-3.0.0.jar!/:3.0.0]
isbn-stacks-kofu        | 	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:383) ~[spring-boot-3.0.0.jar!/:3.0.0]
isbn-stacks-kofu        | 	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-3.0.0.jar!/:3.0.0]
isbn-stacks-kofu        | 	at org.springframework.fu.kofu.KofuApplication.run(KofuApplication.kt:50) ~[spring-fu-kofu-0.5.1.jar!/:na]
isbn-stacks-kofu        | 	at org.springframework.fu.kofu.KofuApplication.run$default(KofuApplication.kt:34) ~[spring-fu-kofu-0.5.1.jar!/:na]
isbn-stacks-kofu        | 	at org.jesperancinha.spring.ISBNStacksKoFuReactiveLauncher$Companion.main(ISBNStacksKoFuReactiveLauncher.kt:48) ~[classes!/:na]
isbn-stacks-kofu        | 	at org.jesperancinha.spring.ISBNStacksKoFuReactiveLauncher.main(ISBNStacksKoFuReactiveLauncher.kt) ~[classes!/:na]
isbn-stacks-kofu        | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
isbn-stacks-kofu        | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
isbn-stacks-kofu        | 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
isbn-stacks-kofu        | 	at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.Launcher.launch(Launcher.java:95) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | Caused by: java.lang.ClassNotFoundException: org.jesperancinha.spring.ISBNStacksKoFuReactiveLauncher$Companion__ApplicationContextInitializer
isbn-stacks-kofu        | 	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:432) ~[na:na]
isbn-stacks-kofu        | 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:586) ~[na:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:149) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | 	at org.springframework.fu.kofu.KofuApplication.run(KofuApplication.kt:50) ~[spring-fu-kofu-0.5.1.jar!/:na]
isbn-stacks-kofu        | 	at org.springframework.fu.kofu.KofuApplication.run$default(KofuApplication.kt:34) ~[spring-fu-kofu-0.5.1.jar!/:na]
isbn-stacks-kofu        | 	at org.jesperancinha.spring.ISBNStacksKoFuReactiveLauncher$Companion.main(ISBNStacksKoFuReactiveLauncher.kt:48) ~[classes!/:na]
isbn-stacks-kofu        | 	at org.jesperancinha.spring.ISBNStacksKoFuReactiveLauncher.main(ISBNStacksKoFuReactiveLauncher.kt) ~[classes!/:na]
isbn-stacks-kofu        | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
isbn-stacks-kofu        | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
isbn-stacks-kofu        | 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
isbn-stacks-kofu        | 	at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.Launcher.launch(Launcher.java:95) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | Caused by: java.lang.ClassNotFoundException: org.jesperancinha.spring.ISBNStacksKoFuReactiveLauncher$Companion__ApplicationContextInitializer
isbn-stacks-kofu        | 	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:432) ~[na:na]
isbn-stacks-kofu        | 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:586) ~[na:na]
isbn-stacks-kofu        | 	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:149) ~[isbn-stacks-rest-kofu-mvc-reactive.jar:na]
isbn-stacks-kofu        | 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[na:na]
isbn-stacks-kofu        | 	at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
isbn-stacks-kofu        | 	at java.base/java.lang.Class.forName(Class.java:466) ~[na:na]
isbn-stacks-kofu        | 	at org.springframework.util.ClassUtils.forName(ClassUtils.java:283) ~[spring-core-6.0.2.jar!/:6.0.2]
isbn-stacks-kofu        | 	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:323) ~[spring-core-6.0.2.jar!/:6.0.2]
isbn-stacks-kofu        | 	... 18 common frames omitted

And now, with my fix:

class ISBNStacksNothingLauncher{
    companion object{
        @JvmStatic
        fun main(args: Array<String>) {
            app.run()
        }
    }
    class Companion__ApplicationContextInitializer :
        AotApplicationContextInitializer<ReactiveWebServerApplicationContext> {
        override fun initialize(applicationContext: ReactiveWebServerApplicationContext) {
            applicationContext.registerBean(SampleHandler::class.java, *arrayOf())
        }
    }
}

which does not fix anything apparently, I'm getting this:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.autoconfigure.jackson.JacksonInitializer.lambda$initialize$0(JacksonInitializer.java:44)

The following method did not exist:

The project is located here:
https://github.com/jesperancinha/isbn-stacks

And the first error you can see it here:
https://github.com/jesperancinha/isbn-stacks/actions/runs/3576450272/jobs/6014271816

Maybe I'm missing a dependency or maybe this has a new configuration with Spring 3.0.0? Let me know! thanks in advance!

Yeah for now, Spring Fu is not compatible with Spring Boot 3.

@sdeleuze , do you have plans to make it compatible?

Short term no, we will decide in 2023 if we upgrade or not.

Hi @sdeleuze , I had a look at the status of this project it seems to be quite still... Are you accepting PRs/MRs at the moment? If I submit one of these to fix this problem are you and your team still available to review it and if ok, accept it?

Hi, yes, if somebody takes the time to craft a PR to upgrade Spring Fu to Spring Boot 3 and Spring Framework 6 I can review/merge it. It should support both JaFu and KoFu to be mergeable.

@sdeleuze I see in the gradle file that it is configured to use Java 8 as both source and target. Is this a requirement or can this be upgraded to Java 17?

@sdeleuze also the same question about JaFu. It is using Java 11 for both source and target. Can this also be upgraded to 17? Spring Boot 3.0.0 and newer versions aren't very compatible (if compatible at all) with anything under or equal to Java 11

Should be upgraded to Java 17 as this is a requirement for Spring Boot 3 and Spring Framework 6.

Great thanks, I've made a fork out of this project and will try in my free time to get this to work: https://github.com/jesperancinha/spring-fu

There is a lot of usage of some old dependencies and Javax, so this will be a nice challenge to go through :)

Hey there! I've been working on a fork of spring-fu project called kofu ๐Ÿ˜„. Its goal is to adapt a subset of this project for use with Spring Boot 3. It's nowhere near completion yet most of the unit tests from spring-fu complete successfully. You can find it here: https://github.com/nk2IsHere/kofu.

@sdeleuze now when Spring Boot 3 is out - may we possibly ask you to share your vision regarding the future of KoFu/JaFu projects? Will it be merged in the Spring Boot eventually or ?

Also related side question - I have seen Kotlin DSL in the some examples, but I have not found a dedicated section in the Spring Boot Reference Documentation. Where we can find one ?

Hi, the status is still the one shared in the README, not much update to share yet as we are working on other priorities:

Spring Fu is experimental and not intended to be used in production. The project has been stalled for some time, and we recognize that Spring Fu has not been getting the attention it deserves. The reason for this is that we have been focussed on other projects, such as native compilation and AOT. Rest assured that we will work on functional configurations again in the future, be it through Spring Fu, or in another form.

Most of the DSL are documented at Spring Framework level, see https://docs.spring.io/spring-framework/reference/languages/kotlin.html.

Many thanks for the update on KoFu and the link to the DSL documentation! It's all absolutely clear now.

Just a follow up question regarding documentation best practices in Spring Boot - shall one consider mentioning of this Spring Framework in the Spring Boot documentation as I believe it's where people normally will be looking for it?

If you find a relevant place in Spring Boot refdoc where that make sense, feel free to submit a PR and the Spring Boot team will evaluate if that makes sense from their POV or not.