春季引导嵌入式Keycloak服务器抛出NoSuchMethodError错误。

huangapple go评论75阅读模式
英文:

Spring Boot Embedded Keycloak server throwing NoSuchMethodError

问题

我一直在研究Spring Boot,并偶然发现了一个关于将Keycloak嵌入Spring应用程序的指南,我认为这将是一个有趣的小项目,所以我一直在按照这个指南进行操作。

我已经实施了所有内容,项目正在构建,但在启动时崩溃。这是错误信息:

java.lang.NoSuchMethodError: 'org.infinispan.configuration.global.GlobalJmxStatisticsConfigurationBuilder org.infinispan.configuration.global.GlobalConfigurationBuilder.globalJmxStatistics()'

我已经搜索了一段时间,但运气不太好。我尝试了一些依赖项的调整,以查看是否遗漏了什么,我还验证了我可以导入org.infinispan.configuration.global.GlobalConfigurationBuilder;,这是可用的,所以可能是版本冲突?任何帮助将不胜感激。

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>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>

希望这对你有帮助。

英文:

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: &#39;org.infinispan.configuration.global.GlobalJmxStatisticsConfigurationBuilder org.infinispan.configuration.global.GlobalConfigurationBuilder.globalJmxStatistics()&#39;

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

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;parent&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
&lt;version&gt;2.3.4.RELEASE&lt;/version&gt;
&lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
&lt;/parent&gt;
&lt;groupId&gt;io.geolaw&lt;/groupId&gt;
&lt;artifactId&gt;keycloaktest&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;name&gt;keycloaktest&lt;/name&gt;
&lt;description&gt;&lt;/description&gt;
&lt;properties&gt;
&lt;java.version&gt;15&lt;/java.version&gt;
&lt;/properties&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
&lt;scope&gt;runtime&lt;/scope&gt;
&lt;optional&gt;true&lt;/optional&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.h2database&lt;/groupId&gt;
&lt;artifactId&gt;h2&lt;/artifactId&gt;
&lt;scope&gt;runtime&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-configuration-processor&lt;/artifactId&gt;
&lt;optional&gt;true&lt;/optional&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
&lt;artifactId&gt;lombok&lt;/artifactId&gt;
&lt;optional&gt;true&lt;/optional&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;exclusions&gt;
&lt;exclusion&gt;
&lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
&lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
&lt;/exclusion&gt;
&lt;/exclusions&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
&lt;artifactId&gt;resteasy-jackson2-provider&lt;/artifactId&gt;
&lt;version&gt;3.11.2.Final&lt;/version&gt;
&lt;type&gt;pom&lt;/type&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.infinispan&lt;/groupId&gt;
&lt;artifactId&gt;infinispan-core&lt;/artifactId&gt;
&lt;version&gt;${infinispan.version}&lt;/version&gt;
&lt;exclusions&gt;
&lt;exclusion&gt;
&lt;groupId&gt;org.jgroups&lt;/groupId&gt;
&lt;artifactId&gt;jgroups&lt;/artifactId&gt;
&lt;/exclusion&gt;
&lt;/exclusions&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.keycloak&lt;/groupId&gt;
&lt;artifactId&gt;keycloak-dependencies-server-all&lt;/artifactId&gt;
&lt;version&gt;10.0.1&lt;/version&gt;
&lt;type&gt;pom&lt;/type&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
&lt;/project&gt;

答案1

得分: 4

> „...所以可能是版本冲突的问题?...

就是这样,基本上。一切都始于…

&lt;parent&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
    &lt;version&gt;2.3.4.RELEASE&lt;/version&gt;
    &lt;relativePath/&gt; &lt;!-- 从仓库中查找父级 --&gt;
&lt;/parent&gt;

你从 Baeldung 的原始 2.2.6.RELEASE 的 Spring Boot 升级到 2.3.4.RELEASE,导致了一系列不兼容的依赖项的级联多米诺效应。

除非你迫切需要使用 2.3.4,我的建议是回滚到 2.2.6.RELEASE。否则,你将需要一把与你的手臂一样长的大砍刀,来穿越由此升级引起的不兼容依赖的纠缠不清的混乱。

我已经将 这个可工作的演示 推送,以确认 2.2.6.RELEASE 至少可以在 JDK 15 上工作。

英文:

> „…so could be version conflicts?…

That is it, essentially. It all starts with…

&lt;parent&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
    &lt;version&gt;2.3.4.RELEASE&lt;/version&gt;
    &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
&lt;/parent&gt;

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.

答案2

得分: 0

我遇到了相同的问题。
我已经在我的pom.xml中更新了最大版本

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.12.RELEASE</version>
    <relativePath />
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>15</java.version>

    <keycloak.version>11.0.3</keycloak.version>

    <!-- 这些应该与Keycloak一起更新 -->
    <!-- 检查keycloak-dependencies-server-all的有效pom -->
    <infinispan.version>10.1.8.Final</infinispan.version>
    <resteasy.version>3.12.1.Final</resteasy.version>
</properties>

我尝试将Keycloak更新到11.0.4版本以上,将Spring Boot更新到2.3.12.RELEASE以上,但是不可能的,版本不兼容。也许有人知道如何更新?

英文:

I have the same issue.
The maximum versions i have updated in my pom.xml

&lt;parent&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
&lt;version&gt;2.3.12.RELEASE&lt;/version&gt;
&lt;relativePath /&gt;
&lt;/parent&gt;
&lt;properties&gt;
&lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
&lt;java.version&gt;15&lt;/java.version&gt;
&lt;keycloak.version&gt;11.0.3&lt;/keycloak.version&gt;
&lt;!-- these should be updated together with Keycloak --&gt;
&lt;!-- check keycloak-dependencies-server-all effective pom --&gt;
&lt;infinispan.version&gt;10.1.8.Final&lt;/infinispan.version&gt;
&lt;resteasy.version&gt;3.12.1.Final&lt;/resteasy.version&gt;
&lt;/properties&gt;

I have tried to update the keycloak to any versions more than 11.0.4 version and the spring boot more than 2.3.12.RELEASE but it's impossible - incompatible versions. Maybe who knowns how to update?

huangapple
  • 本文由 发表于 2020年10月12日 15:04:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/64313090.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定