Issue
I've been playing around with spring boot and stumbled onto a guide about embedding Keycloak into a Spring Application, I thought this would a fun little project so I have been following This guide.
I have implemented everything and the project is building, but crashing at start. This is the error:
java.lang.NoSuchMethodError: 'org.infinispan.configuration.global.GlobalJmxStatisticsConfigurationBuilder org.infinispan.configuration.global.GlobalConfigurationBuilder.globalJmxStatistics()'
I've searched around for a bit and haven't had much luck. I've tried messing around with the dependencies to see if I am missing something, I have also verified that I can import org.infinispan.configuration.global.GlobalConfigurationBuilder;
which is available, so could be version conflicts? Any help would be appreciated.
pom.xml
<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>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.geolaw</groupId>
<artifactId>keycloaktest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>keycloaktest</name>
<description></description>
<properties>
<java.version>15</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.11.2.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
<version>${infinispan.version}</version>
<exclusions>
<exclusion>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-dependencies-server-all</artifactId>
<version>10.0.1</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Solution
„…so could be version conflicts?…“
That is it, essentially. It all starts with…
…
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
…
You upgrading from Baeldung's original 2.2.6.RELEASE of Spring Boot to 2.3.4.RELEASE, caused a whole cascading domino affect of incompatible dependencies.
Unless you desperately need to be on 2.3.4, my advice is to just roll back to 2.2.6.RELEASE. Or else you'll need a machete as long as your arm to hack your way through the tangled morass of incompatible dependencies that results from that upgrade.
I've pushed this working demo to confirm that 2.2.6.RELEASE at least works with JDK 15.
Answered By - deduper