Интеграция Keycloak с Spring Boot 3 и Undertow: AbstractMethodError из-за отсутствия реализации io.undertow.servlet.ServJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Интеграция Keycloak с Spring Boot 3 и Undertow: AbstractMethodError из-за отсутствия реализации io.undertow.servlet.Serv

Сообщение Anonymous »

Я разрабатываю веб-приложение с использованием Spring Boot 3 с веб-сервером Undertow. Я хочу интегрировать Keycloak в качестве сервера аутентификации для приложения, которое использует возвращенный токен для авторизации. После этого я столкнулся с ошибкой. Однако все работает нормально, когда я переключаюсь на использование веб-сервера Tomcat. Обратите внимание, что я использую Spring Boot 3.3.5 и Java 21.
Есть ли у меня какие-либо ошибки при настройке проектов?
Ошибка, упомянутая ниже:

Код: Выделить всё

org.springframework.context.ApplicationContextException: Unable to start web server
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:619) ~[spring-context-6.1.14.jar:6.1.14]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.5.jar:3.3.5]
at com.megaheart.mymoney.MymoneyApplication.main(MymoneyApplication.java:17) ~[classes/:na]
Caused by: java.lang.AbstractMethodError: Receiver class org.keycloak.adapters.undertow.KeycloakServletExtension does not define or inherit an implementation of the resolved method 'abstract void handleDeployment(io.undertow.servlet.api.DeploymentInfo, jakarta.servlet.ServletContext)' of interface io.undertow.servlet.ServletExtension.
at io.undertow.servlet.core.DeploymentManagerImpl.handleExtensions(DeploymentManagerImpl.java:282) ~[undertow-servlet-2.3.18.Final.jar:2.3.18.Final]
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:156) ~[undertow-servlet-2.3.18.Final.jar:2.3.18.Final]
at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory.createManager(UndertowServletWebServerFactory.java:331) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory.getWebServer(UndertowServletWebServerFactory.java:300) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188) ~[spring-boot-3.3.5.jar:3.3.5]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-3.3.5.jar:3.3.5]
...  8 common frames omitted
Ниже приведены pom.xml, application.properties и класс конфигурации:
pom.xml

Код: Выделить всё


4.0.0

org.springframework.boot
spring-boot-starter-parent
3.3.5
  

com.megaheart
mymoney
0.0.1-SNAPSHOT
mymoney
My Money -  H e l p   y o u   m a n a g e   y o u r   m o n e y   e f f e c t i v e l y & l t ; / d e s c r i p t i o n & g t ; < b r   / >         & l t ; u r l / & g t ; < b r   / >         & l t ; l i c e n s e s & g t ; < b r   / >                 & l t ; l i c e n s e / & g t ; < b r   / >         & l t ; / l i c e n s e s & g t ; < b r   / >         & l t ; d e v e l o p e r s & g t ; < b r   / >                 & l t ; d e v e l o p e r / & g t ; < b r   / >         & l t ; / d e v e l o p e r s & g t ; < b r   / >         & l t ; s c m & g t ; < b r   / >                 & l t ; c o n n e c t i o n / & g t ; < b r   / >                 & l t ; d e v e l o p e r C o n n e c t i o n / & g t ; < b r   / >                 & l t ; t a g / & g t ; < b r   / >                 & l t ; u r l / & g t ; < b r   / >         & l t ; / s c m & g t ; < b r   / >         & l t ; p r o p e r t i e s & g t ; < b r   / >                 & l t ; j a v a . v e r s i o n & g t ; 2 1 & l t ; / j a v a . v e r s i o n & g t ; < b r   / >         & l t ; / p r o p e r t i e s & g t ; < b r   / >         & l t ; d e p e n d e n c i e s & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; o r g . s p r i n g f r a m e w o r k . b o o t & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; s p r i n g - b o o t - s t a r t e r - d a t a - j p a & l t ; / a r t i f a c t I d & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; o r g . s p r i n g f r a m e w o r k . b o o t & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; s p r i n g - b o o t - s t a r t e r - d a t a - r e d i s & l t ; / a r t i f a c t I d & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; o r g . s p r i n g f r a m e w o r k . b o o t & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; s p r i n g - b o o t - s t a r t e r - d a t a - r e d i s - r e a c t i v e & l t ; / a r t i f a c t I d & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; o r g . s p r i n g f r a m e w o r k . b o o t & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; s p r i n g - b o o t - s t a r t e r - w e b & l t ; / a r t i f a c t I d & g t ; < b r   / >                         & l t ; e x c l u s i o n s & g t ; < b r   / >                                 & l t ; e x c l u s i o n & g t ; < b r   / >                                         & l t ; g r o u p I d & g t ; o r g . s p r i n g f r a m e w o r k . b o o t & l t ; / g r o u p I d & g t ; < b r   / >                                         & l t ; a r t i f a c t I d & g t ; s p r i n g - b o o t - s t a r t e r - t o m c a t & l t ; / a r t i f a c t I d & g t ; < b r   / >                                 & l t ; / e x c l u s i o n & g t ; < b r   / >                         & l t ; / e x c l u s i o n s & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; o r g . s p r i n g f r a m e w o r k . b o o t & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; s p r i n g - b o o t - s t a r t e r - u n d e r t o w & l t ; / a r t i f a c t I d & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; i o . u n d e r t o w & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; u n d e r t o w - s e r v l e t & l t ; / a r t i f a c t I d & g t ; < b r   / >                         & l t ; v e r s i o n & g t ; 2 . 3 . 1 8 . F i n a l & l t ; / v e r s i o n & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; o r g . p o s t g r e s q l & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; p o s t g r e s q l & l t ; / a r t i f a c t I d & g t ; < b r   / >                         & l t ; s c o p e & g t ; r u n t i m e & l t ; / s c o p e & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; o r g . p r o j e c t l o m b o k & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; l o m b o k & l t ; / a r t i f a c t I d & g t ; < b r   / >                         & l t ; o p t i o n a l & g t ; t r u e & l t ; / o p t i o n a l & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ; d e p e n d e n c y & g t ; < b r   / >                         & l t ; g r o u p I d & g t ; o r g . s p r i n g f r a m e w o r k . b o o t & l t ; / g r o u p I d & g t ; < b r   / >                         & l t ; a r t i f a c t I d & g t ; s p r i n g - b o o t - s t a r t e r - t e s t & l t ; / a r t i f a c t I d & g t ; < b r   / >                         & l t ; s c o p e & g t ; t e s t & l t ; / s c o p e & g t ; < b r   / >                 & l t ; / d e p e n d e n c y & g t ; < b r   / >                 & l t ;dependency>
io.projectreactor
reactor-test
test


org.springframework.restdocs
spring-restdocs-mockmvc
test


org.springframework.boot
spring-boot-starter-oauth2-resource-server


org.keycloak
keycloak-admin-client
25.0.3


org.keycloak
keycloak-spring-boot-starter
25.0.3


org.modelmapper
modelmapper
3.2.1


org.springdoc
springdoc-openapi-starter-webmvc-ui
2.6.0






org.asciidoctor
asciidoctor-maven-plugin
2.2.1


generate-docs
prepare-package

process-asciidoc


html
book





org.springframework.restdocs
spring-restdocs-asciidoctor
${spring-restdocs.version}




org.springframework.boot
spring-boot-maven-plugin



org.projectlombok
lombok









application.properties

Код: Выделить всё

server.address=0.0.0.0
server.port=6969
spring.application.name=hello
spring.main.allow-bean-definition-overriding=true

# Spring Boot Admin
spring.servlet.multipart.enabled=true
spring.servlet.multipart.file-size-threshold=2KB
spring.servlet.multipart.max-file-size=200MB
spring.servlet.multipart.max-request-size=215MB

# Keycloak configuration
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:8080/realms/hello_realm
OAuth2ResourceServerSecurityConfiguration.java

Код: Выделить всё

@Configuration
@EnableWebSecurity
public class OAuth2ResourceServerSecurityConfiguration {
@Bean
SecurityFilterChain resourceServerSecurityFilterChain(
HttpSecurity http)  throws Exception {
http.oauth2ResourceServer((oauth2) -> oauth2.jwt(Customizer.withDefaults()));

http.sessionManagement(sessions -> {
sessions.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}).csrf(csrf -> {
csrf.disable();
});

http.authorizeHttpRequests(requests -> {
requests.requestMatchers("/api/**").authenticated()
.anyRequest().permitAll();
});

return http.build();
}
}
Спасибо,


Подробнее здесь: https://stackoverflow.com/questions/793 ... r-due-to-m
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»