I upgraded my backend application to spring boot version 3.3.4 and to Java 21 in the POM.xml and now it's like it doesn't even recognize my bean classes or repositories?
What's strange is the application runs PERFECTLY fine LOCALLY. I can start it, use my front-end to connect to it. But ever since upgrading, when I deploy it to Heroku, it builds fine, but nothing works. I tried to mvn-clean-install
one day and noticed it doesn't recognize any of my beans. I have no clue what's going on.
Also, after everytime I try to do mvn clean install
and THEN try to run my application, I get this error:
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-11-13T08:54:17.653-06:00 ERROR 23732 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cardController': Resolution of declared constructors on bean Class [com.church.churchrestservice.controller.CardController] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@5a07e868] failed
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:384) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1314) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1209) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.13.jar:6.1.13]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:971) ~[spring-context-6.1.13.jar:6.1.13]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625) ~[spring-context-6.1.13.jar:6.1.13]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.4.jar:3.3.4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.4.jar:3.3.4]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.4.jar:3.3.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.4.jar:3.3.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.4.jar:3.3.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.4.jar:3.3.4]
at com.church.churchrestservice.ChurchRestServiceApplication.main(ChurchRestServiceApplication.java:12) ~[classes/:na]
Caused by: java.lang.NoClassDefFoundError: com/church/churchrestservice/service/CardService
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3621) ~[na:na]
at java.base/java.lang.Class.getDeclaredConstructors(Class.java:2786) ~[na:na]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:379) ~[spring-beans-6.1.13.jar:6.1.13]
... 18 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.church.churchrestservice.service.CardService
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528) ~[na:na]
... 22 common frames omitted
Otherwise once I refresh my POM.xml, the app works? I am lost.
Here are my errors when I try to mvn clean install
:
[INFO] --- maven-compiler-plugin:3.13.0:compile (default-compile) @ church-rest-service ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 50 source files with javac [debug parameters release 21] to target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[102,80] cannot find symbol
symbol: method getDisplayCards()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[103,36] cannot find symbol
symbol: method getType()
location: variable displayCardResponse of type com.church.churchrestservice.beans.shared.DisplayCardResponse
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[106,36] cannot find symbol
symbol: method getType()
location: variable displayCardResponse of type com.church.churchrestservice.beans.shared.DisplayCardResponse
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[109,36] cannot find symbol
symbol: method getType()
location: variable displayCardResponse of type com.church.churchrestservice.beans.shared.DisplayCardResponse
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[112,36] cannot find symbol
symbol: method getType()
location: variable displayCardResponse of type com.church.churchrestservice.beans.shared.DisplayCardResponse
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[116,54] cannot find symbol
symbol: method getDisplayCards()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[117,54] cannot find symbol
symbol: method getDisplayCards()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[126,69] cannot find symbol
symbol: method getMinistriesWeSupportPage()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[127,74] cannot find symbol
symbol: method getMinistriesWeSupportPage()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[128,33] cannot find symbol
symbol: method setDisplayCards(java.util.ArrayList<com.church.churchrestservice.beans.shared.DisplayCardResponse>)
location: variable ministriesWeSupportModel of type com.church.churchrestservice.beans.shared.MinistriesWeSupportModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[132,60] cannot find symbol
symbol: method getLeadershipPage()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[133,65] cannot find symbol
symbol: method getLeadershipPage()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[134,24] cannot find symbol
symbol: method setDisplayCards(java.util.ArrayList<com.church.churchrestservice.beans.shared.DisplayCardResponse>)
location: variable leadershipModel of type com.church.churchrestservice.beans.shared.LeadershipModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[138,63] cannot find symbol
symbol: method getOurMinistriesPage()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[139,68] cannot find symbol
symbol: method getOurMinistriesPage()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[140,27] cannot find symbol
symbol: method setDisplayCards(java.util.ArrayList<com.church.churchrestservice.beans.shared.DisplayCardResponse>)
location: variable ourMinistriesModel of type com.church.churchrestservice.beans.shared.OurMinistriesModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[145,58] cannot find symbol
symbol: method getMissionsPage()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[146,63] cannot find symbol
symbol: method getMissionsPage()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[147,22] cannot find symbol
symbol: method setDisplayCards(java.util.ArrayList<com.church.churchrestservice.beans.shared.DisplayCardResponse>)
location: variable missionsModel of type com.church.churchrestservice.beans.shared.MissionsModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[150,35] cannot find symbol
symbol: method setMinistriesWeSupportPage(com.church.churchrestservice.beans.shared.MinistriesWeSupportModel)
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[151,35] cannot find symbol
symbol: method setLeadershipPage(com.church.churchrestservice.beans.shared.LeadershipModel)
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[152,35] cannot find symbol
symbol: method setOurMinistriesPage(com.church.churchrestservice.beans.shared.OurMinistriesModel)
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[153,35] cannot find symbol
symbol: method setMissionsPage(com.church.churchrestservice.beans.shared.MissionsModel)
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[158,60] cannot find symbol
symbol: method getAllCalendarInformation()
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[162,72] cannot find symbol
symbol: method getEvents()
location: variable calendarModel of type com.church.churchrestservice.beans.calendar.CalendarModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[163,63] cannot find symbol
symbol: method getDate()
location: variable calendarModel of type com.church.churchrestservice.beans.calendar.CalendarModel
[ERROR] /D:/church-backend/src/main/java/com/church/churchrestservice/service/CardService.java:[176,35] cannot find symbol
symbol: method setAllCalendarInformation(java.util.ArrayList<com.church.churchrestservice.beans.calendar.CalendarModel>)
location: variable allWebsiteInformationModel of type com.church.churchrestservice.beans.website.AllWebsiteInformationModel
[INFO] 27 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.565 s
[INFO] Finished at: 2024-11-13T08:38:07-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project church-rest-service: Compilation failure: Compilation failure:
All those errors are my bean classes it 'can't find' for some reason but it works locally? I don't know what I'm missing. I think something got messed up. I tried deleting my .idea folder, my .m2 folder and still nothing. Any help would be greatly appreciated.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.church</groupId>
<artifactId>church-rest-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>church-rest-service</name>
<description>Backend For Church Application</description>
<packaging>jar</packaging>
<properties>
<java.version>21</java.version>
<maven.compiler.source>23</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
My JAVA_HOME
is: C:\Program Files\Java\jdk-23
It turns out the actual culprit was LOMBOKS @Getter
& @Setter
. I removed all of them on my beans and replaced them with getters and setters and no errors. I don't know what happened in upgrading. But wow was that infuriating.