Explore all Spring open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Spring

spring-boot

v2.6.7

mall

v1.0.1

spring-framework

v5.3.19

jeecg-boot

3.1.0 版本发布,基于代码生成器的企业级低代码平台

apollo

Apollo 2.0.0-RC1 Release

Popular Libraries in Spring

JavaGuide

by Snailclimb doticonjavadoticon

star image 110287 doticonApache-2.0

「Java学习+面试指南」一份涵盖大部分 Java 程序员所需要掌握的核心知识。准备 Java 面试,首选 JavaGuide!

spring-boot

by spring-projects doticonjavadoticon

star image 60742 doticonApache-2.0

Spring Boot

mall

by macrozheng doticonjavadoticon

star image 52180 doticonApache-2.0

mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。

spring-framework

by spring-projects doticonjavadoticon

star image 47171 doticonApache-2.0

Spring Framework

tutorials

by eugenp doticonjavadoticon

star image 30188 doticonMIT

Just Announced - "Learn Spring Security OAuth":

jeecg-boot

by jeecgboot doticonjavadoticon

star image 28804 doticonApache-2.0

「企业级低代码平台」前后端分离架构SpringBoot 2.x,SpringCloud,Ant Design&Vue,Mybatis,Shiro,JWT。强大的代码生成器让前后端代码一键生成,无需写任何代码! 引领新的开发模式OnlineCoding->代码生成->手工MERGE,帮助Java项目解决70%重复工作,让开发更关注业务,既能快速提高效率,帮助公司节省成本,同时又不失灵活性。

apollo

by apolloconfig doticonjavadoticon

star image 26563 doticonApache-2.0

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.

spring-boot-examples

by ityouknow doticonjavadoticon

star image 26196 doticon

about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

apollo

by ctripcorp doticonjavadoticon

star image 25294 doticonApache-2.0

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.

Trending New libraries in Spring

Sa-Token

by dromara doticonjavadoticon

star image 8497 doticonApache-2.0

这可能是史上功能最全的Java权限认证框架!目前已集成——登录认证、权限认证、分布式Session会话、微服务网关鉴权、单点登录、OAuth2.0、踢人下线、Redis集成、前后台分离、记住我模式、模拟他人账号、临时身份切换、账号封禁、多账号认证体系、注解式鉴权、路由拦截式鉴权、花式token生成、自动续签、同端互斥登录、会话治理、密码加密、jwt集成、Spring集成、WebFlux集成...

sa-token

by dromara doticonjavadoticon

star image 3542 doticonApache-2.0

这可能是史上功能最全的Java权限认证框架!目前已集成——登录认证、权限认证、分布式Session会话、微服务网关鉴权、单点登录、OAuth2.0、踢人下线、Redis集成、前后台分离、记住我模式、模拟他人账号、临时身份切换、账号封禁、多账号认证体系、注解式鉴权、路由拦截式鉴权、花式token生成、自动续签、同端互斥登录、会话治理、密码加密、jwt集成、Spring集成、WebFlux集成...

SpringBootVulExploit

by LandGrey doticonjavadoticon

star image 2694 doticon

SpringBoot 相关漏洞学习资料,利用方法和技巧合集,黑盒安全评估 check list

jetlinks-community

by jetlinks doticonjavadoticon

star image 2534 doticonApache-2.0

JetLinks 基于Java8,Spring Boot 2.x ,WebFlux,Netty,Vert.x,Reactor等开发, 是一个全响应式的企业级物联网平台。支持统一物模型管理,多种设备,多种厂家,统一管理。统一设备连接管理,多协议适配(TCP,MQTT,UDP,CoAP,HTTP等),屏蔽网络编程复杂性,灵活接入不同厂家不同协议等设备。实时数据处理,设备告警,消息通知,数据转发。地理位置,数据可视化等。能帮助你快速建立物联网相关业务系统。

dgs-framework

by Netflix doticonkotlindoticon

star image 2225 doticonApache-2.0

GraphQL for Java with Spring Boot made easy.

small-spring

by fuzhengwei doticonjavadoticon

star image 1925 doticonApache-2.0

🌱《 Spring 手撸专栏》,本专栏以 Spring 源码学习为目的,通过手写简化版 Spring 框架,了解 Spring 核心原理。在手写的过程中会简化 Spring 源码,摘取整体框架中的核心逻辑,简化代码实现过程,保留核心功能,例如:IOC、AOP、Bean生命周期、上下文、作用域、资源处理等内容实现。

erupt

by erupts doticonjavadoticon

star image 1579 doticonApache-2.0

🚀 纯 Java 注解,单个类文件,快速开发 Admin 管理后台。不生成任何代码、零前端代码、零 CURD、自动建表、注解式API、自定义服务逻辑,支持所有主流数据库,支持自定义页面,支持多数据源,提供二十几类业务组件,十几种展示形式,支持逻辑删除,动态定时任务,前端后端分离等。核心技术:Spring Boot、JPA、Reflect、TypeScript、NG-ZORRO等。 开源不易,记得右上角点个star鼓励作者~

SuperMarket

by GoogleLLP doticonjavadoticon

star image 1400 doticonAGPL-3.0

设计精良的网上商城系统,包括前端、后端、数据库、负载均衡、数据库缓存、分库分表、读写分离、全文检索、消息队列等,使用SpringCloud框架,基于Java开发。该项目可部署到服务器上,不断完善中……

retrofit-spring-boot-starter

by LianjiaTech doticonjavadoticon

star image 1166 doticonApache-2.0

A springboot starter for retrofit, and supports many functional feature enhancements, greatly simplifying development.(实现了Retrofit与spring-boot框架快速整合,并支持了诸多功能增强,极大简化开发)

Top Authors in Spring

1

spring-projects

71 Libraries

star icon149911

2

PacktPublishing

54 Libraries

star icon1425

3

21503882

46 Libraries

star icon224

4

hendisantika

43 Libraries

star icon203

5

springframeworkguru

40 Libraries

star icon1526

6

spring-guides

39 Libraries

star icon5714

7

TechPrimers

37 Libraries

star icon1058

8

piomin

34 Libraries

star icon978

9

making

32 Libraries

star icon773

10

joshlong

32 Libraries

star icon1894

1

71 Libraries

star icon149911

2

54 Libraries

star icon1425

3

46 Libraries

star icon224

4

43 Libraries

star icon203

5

40 Libraries

star icon1526

6

39 Libraries

star icon5714

7

37 Libraries

star icon1058

8

34 Libraries

star icon978

9

32 Libraries

star icon773

10

32 Libraries

star icon1894

Trending Kits in Spring

No Trending Kits are available at this moment for Spring

Trending Discussions on Spring

I can't update my webapp to Spring Boot 2.6.0 (2.5.7 works but 2.6.0 doesn't)

EmbeddedKafka failing since Spring Boot 2.6.X : AccessDeniedException: ..\AppData\Local\Temp\spring.kafka*

Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'

IntelliJ - Invalid source release: 17

Spring Cloud Gateway; Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway Issue

Springfox 3.0.0 is not working with Spring Boot 2.6.0

Spring Boot WebClient stops sending requests

Java 17: Maven doesn't give much information about the error that happened, why?

@EnableAutoConfiguration(exclude =...) on tests failed in Spring Boot 2.6.0

How to edit configmap configuration in spring boot kubernetes application during runtime

QUESTION

I can't update my webapp to Spring Boot 2.6.0 (2.5.7 works but 2.6.0 doesn't)

Asked 2022-Apr-05 at 04:24

As mentioned in the title I can't update my webapp to Spring Boot 2.6.0. I wrote my webapp using Spring Boot 2.5.5 and everything works perfectly. If I update the pom.xml file with this new tag:

1<version>2.5.7</version>
2

My webapp works perfectly. All tests work. If I perform this update the webapp does not start:

1<version>2.5.7</version>
2<version>2.6.0</version>
3

Starting the DEBUG mode the IDE shows me an error and 2 links to 2 classes of my webapp.

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6

It seems the problem is in this class:

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6@Configuration
7@EnableWebSecurity
8public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
9
10    @Autowired
11    LivelliDeiRuoli livelliDeiRuoli;
12
13    @Autowired
14    GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
15
16    @Bean
17    public BCryptPasswordEncoder metodoCrittografia() {
18        return new BCryptPasswordEncoder();
19    }
20
21    @Autowired
22    public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
23        auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
24    }
25
26    @Override
27    protected void configure(HttpSecurity http) throws Exception {
28
29        http.csrf().disable();
30
31        http.authorizeRequests().antMatchers(
32                "/",
33                "/login",
34                "/benvenuto",
35                "/registrazione",
36                "/registrazione-eseguita",
37                "/pagine-applicazione"
38        ).permitAll();
39
40        http.authorizeRequests().antMatchers("/area-riservata")
41                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
42
43        http.authorizeRequests().antMatchers("/cambio-password")
44                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
45
46        http.authorizeRequests().antMatchers("/cambio-nome")
47                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
48
49        http.authorizeRequests().antMatchers("/cancella-utente")
50                .access("isAuthenticated()");
51
52        http.authorizeRequests().antMatchers("/gestione-utenti")
53                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
54
55        http.authorizeRequests().antMatchers("/gestione-ruoli")
56                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
57
58        http.authorizeRequests().antMatchers("/pannello-di-controllo")
59                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
60
61        http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
62
63        http.authorizeRequests().and().formLogin()
64                .loginProcessingUrl("/pagina-login")
65                .loginPage("/login")
66                .defaultSuccessUrl("/")
67                .failureUrl("/login?errore=true")
68                .usernameParameter("username")
69                .passwordParameter("password")
70                .and().logout().logoutUrl("/pagina-logout")
71                .logoutSuccessUrl("/login?logout=true");
72
73        http.authorizeRequests().and() //
74                .rememberMe().tokenRepository(this.persistentTokenRepository()) //
75                .tokenValiditySeconds(365 * 24 * 60 * 60);
76                
77        http.authorizeRequests().antMatchers("/gestione-eventi")
78                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
79
80        http.authorizeRequests().antMatchers(
81                "/cerca-eventi",
82                "/ultimi-eventi"
83        ).permitAll();
84
85    }
86
87    @Autowired
88    private DataSource dataSource;
89
90    @Bean
91    public PersistentTokenRepository persistentTokenRepository() {
92        JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
93        db.setDataSource(dataSource);
94        return db;
95    }
96
97    @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
98    @Override
99    public AuthenticationManager authenticationManagerBean() throws Exception {
100        return super.authenticationManagerBean();
101    }
102
103}
104

or in this:

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6@Configuration
7@EnableWebSecurity
8public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
9
10    @Autowired
11    LivelliDeiRuoli livelliDeiRuoli;
12
13    @Autowired
14    GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
15
16    @Bean
17    public BCryptPasswordEncoder metodoCrittografia() {
18        return new BCryptPasswordEncoder();
19    }
20
21    @Autowired
22    public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
23        auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
24    }
25
26    @Override
27    protected void configure(HttpSecurity http) throws Exception {
28
29        http.csrf().disable();
30
31        http.authorizeRequests().antMatchers(
32                "/",
33                "/login",
34                "/benvenuto",
35                "/registrazione",
36                "/registrazione-eseguita",
37                "/pagine-applicazione"
38        ).permitAll();
39
40        http.authorizeRequests().antMatchers("/area-riservata")
41                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
42
43        http.authorizeRequests().antMatchers("/cambio-password")
44                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
45
46        http.authorizeRequests().antMatchers("/cambio-nome")
47                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
48
49        http.authorizeRequests().antMatchers("/cancella-utente")
50                .access("isAuthenticated()");
51
52        http.authorizeRequests().antMatchers("/gestione-utenti")
53                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
54
55        http.authorizeRequests().antMatchers("/gestione-ruoli")
56                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
57
58        http.authorizeRequests().antMatchers("/pannello-di-controllo")
59                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
60
61        http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
62
63        http.authorizeRequests().and().formLogin()
64                .loginProcessingUrl("/pagina-login")
65                .loginPage("/login")
66                .defaultSuccessUrl("/")
67                .failureUrl("/login?errore=true")
68                .usernameParameter("username")
69                .passwordParameter("password")
70                .and().logout().logoutUrl("/pagina-logout")
71                .logoutSuccessUrl("/login?logout=true");
72
73        http.authorizeRequests().and() //
74                .rememberMe().tokenRepository(this.persistentTokenRepository()) //
75                .tokenValiditySeconds(365 * 24 * 60 * 60);
76                
77        http.authorizeRequests().antMatchers("/gestione-eventi")
78                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
79
80        http.authorizeRequests().antMatchers(
81                "/cerca-eventi",
82                "/ultimi-eventi"
83        ).permitAll();
84
85    }
86
87    @Autowired
88    private DataSource dataSource;
89
90    @Bean
91    public PersistentTokenRepository persistentTokenRepository() {
92        JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
93        db.setDataSource(dataSource);
94        return db;
95    }
96
97    @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
98    @Override
99    public AuthenticationManager authenticationManagerBean() throws Exception {
100        return super.authenticationManagerBean();
101    }
102
103}
104@SpringBootApplication
105@Profile("sviluppo")
106public class GestioneUtentiApplication extends SpringBootServletInitializer {
107
108    @Override
109    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
110        return application.sources(GestioneUtentiApplication.class);
111    }
112
113    public static void main(String[] args) {
114        System.setProperty("server.servlet.context-path", "/gestioneutenti");
115        SpringApplication.run(GestioneUtentiApplication.class, args);
116    }
117
118}
119

What's wrong with these classes?

What changes with Spring Boot 2.6.0?

GestioneUtentiSpringSecurity implements UserDetailsService:

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6@Configuration
7@EnableWebSecurity
8public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
9
10    @Autowired
11    LivelliDeiRuoli livelliDeiRuoli;
12
13    @Autowired
14    GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
15
16    @Bean
17    public BCryptPasswordEncoder metodoCrittografia() {
18        return new BCryptPasswordEncoder();
19    }
20
21    @Autowired
22    public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
23        auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
24    }
25
26    @Override
27    protected void configure(HttpSecurity http) throws Exception {
28
29        http.csrf().disable();
30
31        http.authorizeRequests().antMatchers(
32                "/",
33                "/login",
34                "/benvenuto",
35                "/registrazione",
36                "/registrazione-eseguita",
37                "/pagine-applicazione"
38        ).permitAll();
39
40        http.authorizeRequests().antMatchers("/area-riservata")
41                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
42
43        http.authorizeRequests().antMatchers("/cambio-password")
44                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
45
46        http.authorizeRequests().antMatchers("/cambio-nome")
47                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
48
49        http.authorizeRequests().antMatchers("/cancella-utente")
50                .access("isAuthenticated()");
51
52        http.authorizeRequests().antMatchers("/gestione-utenti")
53                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
54
55        http.authorizeRequests().antMatchers("/gestione-ruoli")
56                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
57
58        http.authorizeRequests().antMatchers("/pannello-di-controllo")
59                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
60
61        http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
62
63        http.authorizeRequests().and().formLogin()
64                .loginProcessingUrl("/pagina-login")
65                .loginPage("/login")
66                .defaultSuccessUrl("/")
67                .failureUrl("/login?errore=true")
68                .usernameParameter("username")
69                .passwordParameter("password")
70                .and().logout().logoutUrl("/pagina-logout")
71                .logoutSuccessUrl("/login?logout=true");
72
73        http.authorizeRequests().and() //
74                .rememberMe().tokenRepository(this.persistentTokenRepository()) //
75                .tokenValiditySeconds(365 * 24 * 60 * 60);
76                
77        http.authorizeRequests().antMatchers("/gestione-eventi")
78                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
79
80        http.authorizeRequests().antMatchers(
81                "/cerca-eventi",
82                "/ultimi-eventi"
83        ).permitAll();
84
85    }
86
87    @Autowired
88    private DataSource dataSource;
89
90    @Bean
91    public PersistentTokenRepository persistentTokenRepository() {
92        JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
93        db.setDataSource(dataSource);
94        return db;
95    }
96
97    @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
98    @Override
99    public AuthenticationManager authenticationManagerBean() throws Exception {
100        return super.authenticationManagerBean();
101    }
102
103}
104@SpringBootApplication
105@Profile("sviluppo")
106public class GestioneUtentiApplication extends SpringBootServletInitializer {
107
108    @Override
109    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
110        return application.sources(GestioneUtentiApplication.class);
111    }
112
113    public static void main(String[] args) {
114        System.setProperty("server.servlet.context-path", "/gestioneutenti");
115        SpringApplication.run(GestioneUtentiApplication.class, args);
116    }
117
118}
119@Service
120public class GestioneUtentiSpringSecurity implements UserDetailsService {
121
122    @Autowired
123    private UtenteRepository utenteRepository;
124
125    @Autowired
126    private RuoloRepository ruoloRepository;
127
128    @Autowired
129    EseguiVariabiliDiSistema eseguiVariabiliDiSistema;
130    
131    @Autowired
132    LivelliDeiRuoli livelliDeiRuoli;
133
134    @Override
135    public UserDetails loadUserByUsername(String nomeUtente) throws UsernameNotFoundException {
136
137        Utente utente = trovaUtenteConPrivilegiDiAutenticazione(nomeUtente);
138
139        if (utente == null) {
140            throw new UsernameNotFoundException("L'utente " + nomeUtente + " non è stato trovato nel database.");
141        }
142
143        List<String> ruoliUtente = null;
144        try {
145            ruoliUtente = this.ruoloRepository.trovaRuoliUtente(utente.getId());
146        }catch (Exception b){
147            ruoliUtente = null;
148        }
149
150        List<GrantedAuthority> grantList = null;
151        try{
152            grantList = new ArrayList<GrantedAuthority>();
153            if (ruoliUtente != null) {
154                for (String ruolo : ruoliUtente) {
155                    GrantedAuthority authority = new SimpleGrantedAuthority(ruolo);
156                    grantList.add(authority);
157                }
158            }
159        }catch (Exception c){
160            grantList = null;
161        }
162
163        UserDetails userDetails = null;
164        if((utente != null) && (ruoliUtente != null) && (grantList != null)){
165            userDetails = (UserDetails) new User(utente.getNome(), utente.getPassword(), grantList);
166        }
167        return userDetails;
168    }
169
170    public Utente trovaUtenteConPrivilegiDiAutenticazione(String nomeUtente){
171        try{
172            Utente utente = utenteRepository.trovaUtente(nomeUtente);
173            if(livelliDeiRuoli.requisitiUtenteConRuoloMassimo(utente)){
174                return utente;
175            } else{
176                eseguiVariabiliDiSistema.trovaVariabileSenzaVerificaUtente(
177                        new VariabileSistema(0L, "login", "")
178                );
179                if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("true")){
180                    return utente;
181                }else if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("false")){
182                    return null;
183                }else{
184                    return null;
185                }
186            }
187        }catch (Exception e){
188            return null;
189        }
190    }
191
192}
193

ANSWER

Answered 2021-Nov-23 at 00:04

Starting on Spring Boot 2.6, circular dependencies are prohibited by default. you can allow circular references again by setting the following property:

1<version>2.5.7</version>
2<version>2.6.0</version>
32021-11-23 00:31:45.419 ERROR 21884 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
4
5org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'configurazioneSpringSecurity': Requested bean is currently in creation: Is there an unresolvable circular reference?
6@Configuration
7@EnableWebSecurity
8public class ConfigurazioneSpringSecurity extends WebSecurityConfigurerAdapter {
9
10    @Autowired
11    LivelliDeiRuoli livelliDeiRuoli;
12
13    @Autowired
14    GestioneUtentiSpringSecurity gestioneUtentiSpringSecurity;
15
16    @Bean
17    public BCryptPasswordEncoder metodoCrittografia() {
18        return new BCryptPasswordEncoder();
19    }
20
21    @Autowired
22    public void crittografiaPassword(AuthenticationManagerBuilder auth) throws Exception {
23        auth.userDetailsService(gestioneUtentiSpringSecurity).passwordEncoder(metodoCrittografia());
24    }
25
26    @Override
27    protected void configure(HttpSecurity http) throws Exception {
28
29        http.csrf().disable();
30
31        http.authorizeRequests().antMatchers(
32                "/",
33                "/login",
34                "/benvenuto",
35                "/registrazione",
36                "/registrazione-eseguita",
37                "/pagine-applicazione"
38        ).permitAll();
39
40        http.authorizeRequests().antMatchers("/area-riservata")
41                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
42
43        http.authorizeRequests().antMatchers("/cambio-password")
44                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
45
46        http.authorizeRequests().antMatchers("/cambio-nome")
47                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(1L) + "')");
48
49        http.authorizeRequests().antMatchers("/cancella-utente")
50                .access("isAuthenticated()");
51
52        http.authorizeRequests().antMatchers("/gestione-utenti")
53                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
54
55        http.authorizeRequests().antMatchers("/gestione-ruoli")
56                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
57
58        http.authorizeRequests().antMatchers("/pannello-di-controllo")
59                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(3L) + "')");
60
61        http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/errore-403");
62
63        http.authorizeRequests().and().formLogin()
64                .loginProcessingUrl("/pagina-login")
65                .loginPage("/login")
66                .defaultSuccessUrl("/")
67                .failureUrl("/login?errore=true")
68                .usernameParameter("username")
69                .passwordParameter("password")
70                .and().logout().logoutUrl("/pagina-logout")
71                .logoutSuccessUrl("/login?logout=true");
72
73        http.authorizeRequests().and() //
74                .rememberMe().tokenRepository(this.persistentTokenRepository()) //
75                .tokenValiditySeconds(365 * 24 * 60 * 60);
76                
77        http.authorizeRequests().antMatchers("/gestione-eventi")
78                .access("hasAnyRole('" + livelliDeiRuoli.elencoRuoli(2L) + "')");
79
80        http.authorizeRequests().antMatchers(
81                "/cerca-eventi",
82                "/ultimi-eventi"
83        ).permitAll();
84
85    }
86
87    @Autowired
88    private DataSource dataSource;
89
90    @Bean
91    public PersistentTokenRepository persistentTokenRepository() {
92        JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
93        db.setDataSource(dataSource);
94        return db;
95    }
96
97    @Bean(name = BeanIds.AUTHENTICATION_MANAGER)
98    @Override
99    public AuthenticationManager authenticationManagerBean() throws Exception {
100        return super.authenticationManagerBean();
101    }
102
103}
104@SpringBootApplication
105@Profile("sviluppo")
106public class GestioneUtentiApplication extends SpringBootServletInitializer {
107
108    @Override
109    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
110        return application.sources(GestioneUtentiApplication.class);
111    }
112
113    public static void main(String[] args) {
114        System.setProperty("server.servlet.context-path", "/gestioneutenti");
115        SpringApplication.run(GestioneUtentiApplication.class, args);
116    }
117
118}
119@Service
120public class GestioneUtentiSpringSecurity implements UserDetailsService {
121
122    @Autowired
123    private UtenteRepository utenteRepository;
124
125    @Autowired
126    private RuoloRepository ruoloRepository;
127
128    @Autowired
129    EseguiVariabiliDiSistema eseguiVariabiliDiSistema;
130    
131    @Autowired
132    LivelliDeiRuoli livelliDeiRuoli;
133
134    @Override
135    public UserDetails loadUserByUsername(String nomeUtente) throws UsernameNotFoundException {
136
137        Utente utente = trovaUtenteConPrivilegiDiAutenticazione(nomeUtente);
138
139        if (utente == null) {
140            throw new UsernameNotFoundException("L'utente " + nomeUtente + " non è stato trovato nel database.");
141        }
142
143        List<String> ruoliUtente = null;
144        try {
145            ruoliUtente = this.ruoloRepository.trovaRuoliUtente(utente.getId());
146        }catch (Exception b){
147            ruoliUtente = null;
148        }
149
150        List<GrantedAuthority> grantList = null;
151        try{
152            grantList = new ArrayList<GrantedAuthority>();
153            if (ruoliUtente != null) {
154                for (String ruolo : ruoliUtente) {
155                    GrantedAuthority authority = new SimpleGrantedAuthority(ruolo);
156                    grantList.add(authority);
157                }
158            }
159        }catch (Exception c){
160            grantList = null;
161        }
162
163        UserDetails userDetails = null;
164        if((utente != null) && (ruoliUtente != null) && (grantList != null)){
165            userDetails = (UserDetails) new User(utente.getNome(), utente.getPassword(), grantList);
166        }
167        return userDetails;
168    }
169
170    public Utente trovaUtenteConPrivilegiDiAutenticazione(String nomeUtente){
171        try{
172            Utente utente = utenteRepository.trovaUtente(nomeUtente);
173            if(livelliDeiRuoli.requisitiUtenteConRuoloMassimo(utente)){
174                return utente;
175            } else{
176                eseguiVariabiliDiSistema.trovaVariabileSenzaVerificaUtente(
177                        new VariabileSistema(0L, "login", "")
178                );
179                if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("true")){
180                    return utente;
181                }else if(eseguiVariabiliDiSistema.getVariabileDiSistema().getValore().equals("false")){
182                    return null;
183                }else{
184                    return null;
185                }
186            }
187        }catch (Exception e){
188            return null;
189        }
190    }
191
192}
193spring.main.allow-circular-references = true
194

You can read some more details about this in the Spring Boot 2.6 Release Notes.

Source https://stackoverflow.com/questions/70073748

QUESTION

EmbeddedKafka failing since Spring Boot 2.6.X : AccessDeniedException: ..\AppData\Local\Temp\spring.kafka*

Asked 2022-Mar-25 at 12:39

e: this has been fixed through Spring Boot 2.6.5 (see https://github.com/spring-projects/spring-boot/issues/30243)

Since upgrading to Spring Boot 2.6.X (in my case: 2.6.1), I have multiple projects that now have failing unit-tests on Windows that cannot start EmbeddedKafka, that do run with Linux

There is multiple errors, but this is the first one thrown

1...
2  .   ____          _            __ _ _
3 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
4( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
5 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
6  '  |____| .__|_| |_|_| |_\__, | / / / /
7 =========|_|==============|___/=/_/_/_/
8 :: Spring Boot ::                (v2.6.1)
9
102021-12-09 16:15:00.300  INFO 13864 --- [           main] k.utils.Log4jControllerRegistration$     : Registered kafka:type=kafka.Log4jController MBean
112021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : 
122021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :   ______                  _                                          
132021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :  |___  /                 | |                                         
142021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :     / /    ___     ___   | | __   ___    ___   _ __     ___   _ __   
152021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :    / /    / _ \   / _ \  | |/ /  / _ \  / _ \ | '_ \   / _ \ | '__|
162021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :   / /__  | (_) | | (_) | |   <  |  __/ |  __/ | |_) | |  __/ | |    
172021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :  /_____|  \___/   \___/  |_|\_\  \___|  \___| | .__/   \___| |_|
182021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :                                               | |                     
192021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :                                               |_|                     
202021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : 
212021-12-09 16:15:00.422  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : Server environment:zookeeper.version=3.6.3--6401e4ad2087061bc6b9f80dec2d69f2e3c8660a, built on 04/08/2021 16:35 GMT
222021-12-09 16:15:00.422  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : Server environment:host.name=host.docker.internal
232021-12-09 16:15:00.422  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : Server environment:java.version=11.0.11
242021-12-09 16:15:00.422  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : Server environment:java.vendor=AdoptOpenJDK
25...
262021-12-09 16:15:01.015  INFO 13864 --- [nelReaper-Fetch] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Fetch]: Starting
272021-12-09 16:15:01.015  INFO 13864 --- [lReaper-Produce] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Produce]: Starting
282021-12-09 16:15:01.016  INFO 13864 --- [lReaper-Request] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Request]: Starting
292021-12-09 16:15:01.017  INFO 13864 --- [trollerMutation] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-ControllerMutation]: Starting
302021-12-09 16:15:01.037  INFO 13864 --- [           main] kafka.log.LogManager                     : Loading logs from log dirs ArraySeq(C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446)
312021-12-09 16:15:01.040  INFO 13864 --- [           main] kafka.log.LogManager                     : Attempting recovery for all logs in C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446 since no clean shutdown file was found
322021-12-09 16:15:01.043  INFO 13864 --- [           main] kafka.log.LogManager                     : Loaded 0 logs in 6ms.
332021-12-09 16:15:01.043  INFO 13864 --- [           main] kafka.log.LogManager                     : Starting log cleanup with a period of 300000 ms.
342021-12-09 16:15:01.045  INFO 13864 --- [           main] kafka.log.LogManager                     : Starting log flusher with a default period of 9223372036854775807 ms.
352021-12-09 16:15:01.052  INFO 13864 --- [           main] kafka.log.LogCleaner                     : Starting the log cleaner
362021-12-09 16:15:01.059  INFO 13864 --- [leaner-thread-0] kafka.log.LogCleaner                     : [kafka-log-cleaner-thread-0]: Starting
372021-12-09 16:15:01.224  INFO 13864 --- [name=forwarding] k.s.BrokerToControllerRequestThread      : [BrokerToControllerChannelManager broker=0 name=forwarding]: Starting
382021-12-09 16:15:01.325  INFO 13864 --- [           main] kafka.network.ConnectionQuotas           : Updated connection-accept-rate max connection creation rate to 2147483647
392021-12-09 16:15:01.327  INFO 13864 --- [           main] kafka.network.Acceptor                   : Awaiting socket connections on localhost:63919.
402021-12-09 16:15:01.345  INFO 13864 --- [           main] kafka.network.SocketServer               : [SocketServer listenerType=ZK_BROKER, nodeId=0] Created data-plane acceptor and processors for endpoint : ListenerName(PLAINTEXT)
412021-12-09 16:15:01.350  INFO 13864 --- [0 name=alterIsr] k.s.BrokerToControllerRequestThread      : [BrokerToControllerChannelManager broker=0 name=alterIsr]: Starting
422021-12-09 16:15:01.364  INFO 13864 --- [eaper-0-Produce] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-Produce]: Starting
432021-12-09 16:15:01.364  INFO 13864 --- [nReaper-0-Fetch] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-Fetch]: Starting
442021-12-09 16:15:01.365  INFO 13864 --- [0-DeleteRecords] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-DeleteRecords]: Starting
452021-12-09 16:15:01.365  INFO 13864 --- [r-0-ElectLeader] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-ElectLeader]: Starting
462021-12-09 16:15:01.374  INFO 13864 --- [rFailureHandler] k.s.ReplicaManager$LogDirFailureHandler  : [LogDirFailureHandler]: Starting
472021-12-09 16:15:01.390  INFO 13864 --- [           main] kafka.zk.KafkaZkClient                   : Creating /brokers/ids/0 (is it secure? false)
482021-12-09 16:15:01.400  INFO 13864 --- [           main] kafka.zk.KafkaZkClient                   : Stat of the created znode at /brokers/ids/0 is: 25,25,1639062901396,1639062901396,1,0,0,72059919267528704,204,0,25
49
502021-12-09 16:15:01.400  INFO 13864 --- [           main] kafka.zk.KafkaZkClient                   : Registered broker 0 at path /brokers/ids/0 with addresses: PLAINTEXT://localhost:63919, czxid (broker epoch): 25
512021-12-09 16:15:01.410 ERROR 13864 --- [           main] kafka.server.BrokerMetadataCheckpoint    : Failed to write meta.properties due to
52
53java.nio.file.AccessDeniedException: C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446
54    at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89) ~[na:na]
55    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) ~[na:na]
56    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108) ~[na:na]
57
1...
2  .   ____          _            __ _ _
3 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
4( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
5 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
6  '  |____| .__|_| |_|_| |_\__, | / / / /
7 =========|_|==============|___/=/_/_/_/
8 :: Spring Boot ::                (v2.6.1)
9
102021-12-09 16:15:00.300  INFO 13864 --- [           main] k.utils.Log4jControllerRegistration$     : Registered kafka:type=kafka.Log4jController MBean
112021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : 
122021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :   ______                  _                                          
132021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :  |___  /                 | |                                         
142021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :     / /    ___     ___   | | __   ___    ___   _ __     ___   _ __   
152021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :    / /    / _ \   / _ \  | |/ /  / _ \  / _ \ | '_ \   / _ \ | '__|
162021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :   / /__  | (_) | | (_) | |   <  |  __/ |  __/ | |_) | |  __/ | |    
172021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :  /_____|  \___/   \___/  |_|\_\  \___|  \___| | .__/   \___| |_|
182021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :                                               | |                     
192021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     :                                               |_|                     
202021-12-09 16:15:00.420  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : 
212021-12-09 16:15:00.422  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : Server environment:zookeeper.version=3.6.3--6401e4ad2087061bc6b9f80dec2d69f2e3c8660a, built on 04/08/2021 16:35 GMT
222021-12-09 16:15:00.422  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : Server environment:host.name=host.docker.internal
232021-12-09 16:15:00.422  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : Server environment:java.version=11.0.11
242021-12-09 16:15:00.422  INFO 13864 --- [           main] o.a.zookeeper.server.ZooKeeperServer     : Server environment:java.vendor=AdoptOpenJDK
25...
262021-12-09 16:15:01.015  INFO 13864 --- [nelReaper-Fetch] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Fetch]: Starting
272021-12-09 16:15:01.015  INFO 13864 --- [lReaper-Produce] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Produce]: Starting
282021-12-09 16:15:01.016  INFO 13864 --- [lReaper-Request] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-Request]: Starting
292021-12-09 16:15:01.017  INFO 13864 --- [trollerMutation] lientQuotaManager$ThrottledChannelReaper : [ThrottledChannelReaper-ControllerMutation]: Starting
302021-12-09 16:15:01.037  INFO 13864 --- [           main] kafka.log.LogManager                     : Loading logs from log dirs ArraySeq(C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446)
312021-12-09 16:15:01.040  INFO 13864 --- [           main] kafka.log.LogManager                     : Attempting recovery for all logs in C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446 since no clean shutdown file was found
322021-12-09 16:15:01.043  INFO 13864 --- [           main] kafka.log.LogManager                     : Loaded 0 logs in 6ms.
332021-12-09 16:15:01.043  INFO 13864 --- [           main] kafka.log.LogManager                     : Starting log cleanup with a period of 300000 ms.
342021-12-09 16:15:01.045  INFO 13864 --- [           main] kafka.log.LogManager                     : Starting log flusher with a default period of 9223372036854775807 ms.
352021-12-09 16:15:01.052  INFO 13864 --- [           main] kafka.log.LogCleaner                     : Starting the log cleaner
362021-12-09 16:15:01.059  INFO 13864 --- [leaner-thread-0] kafka.log.LogCleaner                     : [kafka-log-cleaner-thread-0]: Starting
372021-12-09 16:15:01.224  INFO 13864 --- [name=forwarding] k.s.BrokerToControllerRequestThread      : [BrokerToControllerChannelManager broker=0 name=forwarding]: Starting
382021-12-09 16:15:01.325  INFO 13864 --- [           main] kafka.network.ConnectionQuotas           : Updated connection-accept-rate max connection creation rate to 2147483647
392021-12-09 16:15:01.327  INFO 13864 --- [           main] kafka.network.Acceptor                   : Awaiting socket connections on localhost:63919.
402021-12-09 16:15:01.345  INFO 13864 --- [           main] kafka.network.SocketServer               : [SocketServer listenerType=ZK_BROKER, nodeId=0] Created data-plane acceptor and processors for endpoint : ListenerName(PLAINTEXT)
412021-12-09 16:15:01.350  INFO 13864 --- [0 name=alterIsr] k.s.BrokerToControllerRequestThread      : [BrokerToControllerChannelManager broker=0 name=alterIsr]: Starting
422021-12-09 16:15:01.364  INFO 13864 --- [eaper-0-Produce] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-Produce]: Starting
432021-12-09 16:15:01.364  INFO 13864 --- [nReaper-0-Fetch] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-Fetch]: Starting
442021-12-09 16:15:01.365  INFO 13864 --- [0-DeleteRecords] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-DeleteRecords]: Starting
452021-12-09 16:15:01.365  INFO 13864 --- [r-0-ElectLeader] perationPurgatory$ExpiredOperationReaper : [ExpirationReaper-0-ElectLeader]: Starting
462021-12-09 16:15:01.374  INFO 13864 --- [rFailureHandler] k.s.ReplicaManager$LogDirFailureHandler  : [LogDirFailureHandler]: Starting
472021-12-09 16:15:01.390  INFO 13864 --- [           main] kafka.zk.KafkaZkClient                   : Creating /brokers/ids/0 (is it secure? false)
482021-12-09 16:15:01.400  INFO 13864 --- [           main] kafka.zk.KafkaZkClient                   : Stat of the created znode at /brokers/ids/0 is: 25,25,1639062901396,1639062901396,1,0,0,72059919267528704,204,0,25
49
502021-12-09 16:15:01.400  INFO 13864 --- [           main] kafka.zk.KafkaZkClient                   : Registered broker 0 at path /brokers/ids/0 with addresses: PLAINTEXT://localhost:63919, czxid (broker epoch): 25
512021-12-09 16:15:01.410 ERROR 13864 --- [           main] kafka.server.BrokerMetadataCheckpoint    : Failed to write meta.properties due to
52
53java.nio.file.AccessDeniedException: C:\Users\ddrop\AppData\Local\Temp\spring.kafka.bf8e2b62-a1f2-4092-b292-a15e35bd31ad18378079390566696446
54    at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89) ~[na:na]
55    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) ~[na:na]
56    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108) ~[na:na]
57package com.example.demo;
58
59import org.junit.jupiter.api.Test;
60import org.springframework.boot.test.context.SpringBootTest;
61import org.springframework.kafka.test.context.EmbeddedKafka;
62
63@SpringBootTest
64@EmbeddedKafka
65class ApplicationTest {
66
67    @Test
68    void run() {
69        int i = 1 + 1; // just a line of code to set a debug-point
70    }
71}
72

I do not have this error when pinning kafka.version to 2.8.1 in pom.xml's properties.

It seems like the cause is in Kafka itself, but I have a hard time figuring out if it is spring-kafka intitializing Kafka via EmbeddedKafka incorrectly or if Kafka itself is the culrit here.

Anyone has an idea? Am I missing a test-parameter to set?

ANSWER

Answered 2021-Dec-09 at 15:51

Known bug on the Apache Kafka side. Nothing to do from Spring perspective. See more info here: https://github.com/spring-projects/spring-kafka/discussions/2027. And here: https://issues.apache.org/jira/browse/KAFKA-13391

You need to wait until Apache Kafka 3.0.1 or don't use embedded Kafka and just rely on the Testcontainers, for example, or fully external Apache Kafka broker.

Source https://stackoverflow.com/questions/70292425

QUESTION

Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'

Asked 2022-Mar-25 at 06:14

I'm trying to initiate a Springboot project using Open Jdk 15, Springboot 2.6.0, Springfox 3. We are working on a project that replaced Netty as the webserver and used Jetty instead because we do not need a non-blocking environment.

In the code we depend primarily on Reactor API (Flux, Mono), so we can not remove org.springframework.boot:spring-boot-starter-webflux dependencies.

I replicated the problem that we have in a new project.: https://github.com/jvacaq/spring-fox.

I figured out that these lines in our build.gradle file are the origin of the problem.

1compile("org.springframework.boot:spring-boot-starter-web") {
2   exclude module: "spring-boot-starter-tomcat"
3}
4compile("org.springframework.boot:spring-boot-starter-jetty")
5

Here is the build.gradle file:

1compile("org.springframework.boot:spring-boot-starter-web") {
2   exclude module: "spring-boot-starter-tomcat"
3}
4compile("org.springframework.boot:spring-boot-starter-jetty")
5plugins {
6    id 'org.springframework.boot' version '2.6.0'
7    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
8    id 'java'
9}
10
11group = 'com.example'
12version = '0.0.1-SNAPSHOT'
13sourceCompatibility = '11'
14
15repositories {
16    mavenCentral()
17}
18
19dependencies {
20    compile("org.springframework.boot:spring-boot-starter-web") {
21        exclude module: "spring-boot-starter-tomcat"
22    }
23    compile("org.springframework.boot:spring-boot-starter-jetty")
24    implementation 'org.springframework.boot:spring-boot-starter-webflux'
25    testImplementation 'org.springframework.boot:spring-boot-starter-test'
26    testImplementation 'io.projectreactor:reactor-test'
27    implementation "io.springfox:springfox-boot-starter:3.0.0"
28}
29
30test {
31    useJUnitPlatform()
32}
33
34

I issued the command gradle clean bootrun. The result is this error:

1compile("org.springframework.boot:spring-boot-starter-web") {
2   exclude module: "spring-boot-starter-tomcat"
3}
4compile("org.springframework.boot:spring-boot-starter-jetty")
5plugins {
6    id 'org.springframework.boot' version '2.6.0'
7    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
8    id 'java'
9}
10
11group = 'com.example'
12version = '0.0.1-SNAPSHOT'
13sourceCompatibility = '11'
14
15repositories {
16    mavenCentral()
17}
18
19dependencies {
20    compile("org.springframework.boot:spring-boot-starter-web") {
21        exclude module: "spring-boot-starter-tomcat"
22    }
23    compile("org.springframework.boot:spring-boot-starter-jetty")
24    implementation 'org.springframework.boot:spring-boot-starter-webflux'
25    testImplementation 'org.springframework.boot:spring-boot-starter-test'
26    testImplementation 'io.projectreactor:reactor-test'
27    implementation "io.springfox:springfox-boot-starter:3.0.0"
28}
29
30test {
31    useJUnitPlatform()
32}
33
34 gradle clean bootrun                                                                                                                                                                                                               
35
36> Task :bootRun FAILED
37
38  .   ____          _            __ _ _
39 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
40( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
41 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
42  '  |____| .__|_| |_|_| |_\__, | / / / /
43 =========|_|==============|___/=/_/_/_/
44 :: Spring Boot ::                (v2.6.0)
45
462021-11-19 09:41:06.665  INFO 16666 --- [           main] c.e.springfox.SpringFoxApplication       : Starting SpringFoxApplication using Java 15.0.2 on advance-Inspiron-5379 with PID 16666 (/home/advance/projects/spring-fox/build/classes/java/main started by advance in /home/advance/projects/spring-fox)
472021-11-19 09:41:06.666  INFO 16666 --- [           main] c.e.springfox.SpringFoxApplication       : No active profile set, falling back to default profiles: default
482021-11-19 09:41:07.294  INFO 16666 --- [           main] org.eclipse.jetty.util.log               : Logging initialized @1132ms to org.eclipse.jetty.util.log.Slf4jLog
492021-11-19 09:41:07.396  INFO 16666 --- [           main] o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 8080
502021-11-19 09:41:07.398  INFO 16666 --- [           main] org.eclipse.jetty.server.Server          : jetty-9.4.44.v20210927; built: 2021-09-27T23:02:44.612Z; git: 8da83308eeca865e495e53ef315a249d63ba9332; jvm 15.0.2+7-27
512021-11-19 09:41:07.417  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring embedded WebApplicationContext
522021-11-19 09:41:07.417  INFO 16666 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 713 ms
532021-11-19 09:41:07.474  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : DefaultSessionIdManager workerName=node0
542021-11-19 09:41:07.474  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : No SessionScavenger set, using defaults
552021-11-19 09:41:07.475  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : node0 Scavenging every 660000ms
562021-11-19 09:41:07.480  INFO 16666 --- [           main] o.e.jetty.server.handler.ContextHandler  : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@6aa3bfc{application,/,[file:///tmp/jetty-docbase.8080.2024342829220941812/, jar:file:/home/advance/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-swagger-ui/3.0.0/1e665fbe22148f7c36fa8a08e515a0047cd4390b/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],AVAILABLE}
572021-11-19 09:41:07.480  INFO 16666 --- [           main] org.eclipse.jetty.server.Server          : Started @1318ms
582021-11-19 09:41:07.920  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring DispatcherServlet 'dispatcherServlet'
592021-11-19 09:41:07.920  INFO 16666 --- [           main] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
602021-11-19 09:41:07.921  INFO 16666 --- [           main] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
612021-11-19 09:41:07.931  INFO 16666 --- [           main] o.e.jetty.server.AbstractConnector       : Started ServerConnector@2643d762{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
622021-11-19 09:41:07.932  INFO 16666 --- [           main] o.s.b.web.embedded.jetty.JettyWebServer  : Jetty started on port(s) 8080 (http/1.1) with context path '/'
632021-11-19 09:41:07.934  WARN 16666 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
642021-11-19 09:41:07.949  INFO 16666 --- [           main] o.e.jetty.server.AbstractConnector       : Stopped ServerConnector@2643d762{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
652021-11-19 09:41:07.950  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : node0 Stopped scavenging
662021-11-19 09:41:07.951  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Destroying Spring FrameworkServlet 'dispatcherServlet'
672021-11-19 09:41:07.951  INFO 16666 --- [           main] o.e.jetty.server.handler.ContextHandler  : Stopped o.s.b.w.e.j.JettyEmbeddedWebAppContext@6aa3bfc{application,/,[file:///tmp/jetty-docbase.8080.2024342829220941812/, jar:file:/home/advance/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-swagger-ui/3.0.0/1e665fbe22148f7c36fa8a08e515a0047cd4390b/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],STOPPED}
682021-11-19 09:41:07.958  INFO 16666 --- [           main] ConditionEvaluationReportLoggingListener : 
69
70Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
712021-11-19 09:41:07.970 ERROR 16666 --- [           main] o.s.boot.SpringApplication               : Application run failed
72
73org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
74        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.13.jar:5.3.13]
75        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.13.jar:5.3.13]
76        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.13.jar:5.3.13]
77        at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
78        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.13.jar:5.3.13]
79        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.13.jar:5.3.13]
80        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.13.jar:5.3.13]
81        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.13.jar:5.3.13]
82        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.0.jar:2.6.0]
83        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-2.6.0.jar:2.6.0]
84        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.6.0.jar:2.6.0]
85        at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.0.jar:2.6.0]
86        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.0.jar:2.6.0]
87        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.0.jar:2.6.0]
88        at com.example.springfox.SpringFoxApplication.main(SpringFoxApplication.java:10) ~[main/:na]
89Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
90        at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56) ~[springfox-spring-webmvc-3.0.0.jar:3.0.0]
91        at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113) ~[springfox-core-3.0.0.jar:3.0.0]
92        at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89) ~[springfox-spi-3.0.0.jar:3.0.0]
93        at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469) ~[na:na]
94        at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) ~[na:na]
95        at java.base/java.util.TimSort.sort(TimSort.java:220) ~[na:na]
96        at java.base/java.util.Arrays.sort(Arrays.java:1306) ~[na:na]
97        at java.base/java.util.ArrayList.sort(ArrayList.java:1721) ~[na:na]
98        at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:392) ~[na:na]
99        at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
100        at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
101        at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
102        at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
103        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[na:na]
104        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
105        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
106        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
107        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
108        at springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider.requestHandlers(WebMvcRequestHandlerProvider.java:81) ~[springfox-spring-webmvc-3.0.0.jar:3.0.0]
109        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
110        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[na:na]
111        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
112        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
113        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
114        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
115        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
116        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.withDefaults(AbstractDocumentationPluginsBootstrapper.java:107) ~[springfox-spring-web-3.0.0.jar:3.0.0]
117        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.buildContext(AbstractDocumentationPluginsBootstrapper.java:91) ~[springfox-spring-web-3.0.0.jar:3.0.0]
118        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82) ~[springfox-spring-web-3.0.0.jar:3.0.0]
119        at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100) ~[springfox-spring-web-3.0.0.jar:3.0.0]
120        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.13.jar:5.3.13]
121        ... 14 common frames omitted
122
123
124FAILURE: Build failed with an exception.
125
126* What went wrong:
127Execution failed for task ':bootRun'.
128> Process 'command '/home/advance/.sdkman/candidates/java/15.0.2-open/bin/java'' finished with non-zero exit value 1
129
130* Try:
131Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
132
133* Get more help at https://help.gradle.org
134
135Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
136Use '--warning-mode all' to show the individual deprecation warnings.
137See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings
138
139BUILD FAILED in 2s
1405 actionable tasks: 5 executed
141

Does anyone have an idea how to solve it?

ANSWER

Answered 2022-Feb-08 at 12:36

This problem's caused by a bug in Springfox. It's making an assumption about how Spring MVC is set up that doesn't always hold true. Specifically, it's assuming that MVC's path matching will use the Ant-based path matcher and not the PathPattern-based matcher. PathPattern-based matching has been an option for some time now and is the default as of Spring Boot 2.6.

As described in Spring Boot 2.6's release notes, you can restore the configuration that Springfox assumes will be used by setting spring.mvc.pathmatch.matching-strategy to ant-path-matcher in your application.properties file. Note that this will only work if you are not using Spring Boot's Actuator. The Actuator always uses PathPattern-based parsing, irrespective of the configured matching-strategy. A change to Springfox will be required if you want to use it with the Actuator in Spring Boot 2.6 and later.

Source https://stackoverflow.com/questions/70036953

QUESTION

IntelliJ - Invalid source release: 17

Asked 2022-Mar-17 at 13:46

I've created a new Java project in IntelliJ with Gradle that uses Java 17. When running my app it has the error Cause: error: invalid source release: 17.

My Settings

I've installed openjdk-17 through IntelliJ and set it as my Project SDK.

The Project language level has been set to 17 - Sealed types, always-strict floating-point semantics.

enter image description here

In Modules -> Sources I've set the Language level to Project default (17 - Sealed types, always strict floating-point semantics).

modules->sources

In Modules -> Dependencies I've set the Module SDK to Project SDK openjdk-17.

modules->dependencies

In Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler I've set the Project bytecode version to 17.

enter image description here

Gradle

1plugins {
2    id 'org.springframework.boot' version '2.5.6'
3    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
4    id 'java'
5}
6
7group = 'com.app'
8version = '0.0.1-SNAPSHOT'
9sourceCompatibility = '17'
10
11repositories {
12    mavenCentral()
13}
14
15dependencies {
16    implementation 'org.springframework.boot:spring-boot-starter-web'
17    implementation 'org.springframework.boot:spring-boot-starter-websocket'
18    testImplementation 'org.springframework.boot:spring-boot-starter-test'
19    implementation 'com.fasterxml.jackson.core:jackson-core:2.13.0'
20    implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
21}
22
23test {
24    useJUnitPlatform()
25}
26

I've looked at all of the answers here but I can't seem to fix this. I must be missing something but I can't find it. I've not had any problems using Java 8 or 11.

How do I resolve this?

ANSWER

Answered 2021-Oct-24 at 14:23

The message typically entails that your JAVA_HOME environment variable points to a different Java version.

Here are the steps to follow:

  • Close IntelliJ IDEA
  • Open a terminal window and check your JAVA_HOME variable value:
    • *nix system: echo $JAVA_HOME
    • Windows system: echo %JAVA_HOME%
  • The JAVA_HOME path should be pointing to a different path, then set it to the openjdk-17 path:
    • *nix system: export JAVA_HOME=/path/to/openjdk-17
    • Windows system: set JAVA_HOME=path\to\openjdk-17
  • Open your project again in IntelliJ IDEA
  • Make sure to set both source and target compatibility versions (not only the sourceCompatibility)

You should be able to build your project.

EDIT: Gradle Toolchain

You may need also to instruct Gradle to use a different JVM than the one it uses itself by setting the Java plugin toolchain to your target version:

1plugins {
2    id 'org.springframework.boot' version '2.5.6'
3    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
4    id 'java'
5}
6
7group = 'com.app'
8version = '0.0.1-SNAPSHOT'
9sourceCompatibility = '17'
10
11repositories {
12    mavenCentral()
13}
14
15dependencies {
16    implementation 'org.springframework.boot:spring-boot-starter-web'
17    implementation 'org.springframework.boot:spring-boot-starter-websocket'
18    testImplementation 'org.springframework.boot:spring-boot-starter-test'
19    implementation 'com.fasterxml.jackson.core:jackson-core:2.13.0'
20    implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
21}
22
23test {
24    useJUnitPlatform()
25}
26// build.gradle
27java {
28    toolchain {
29        languageVersion = JavaLanguageVersion.of(17)
30    }
31}
32

Source https://stackoverflow.com/questions/69696321

QUESTION

Spring Cloud Gateway; Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway Issue

Asked 2022-Mar-16 at 07:16

I got this below error when run the API-GATEWAY, I tried so many ways but I couldn't solve this issue.

Description:

Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.

Action:

Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.

Main Class

1package com.sample.apigateway;
2
3import org.springframework.boot.SpringApplication;
4import org.springframework.boot.autoconfigure.SpringBootApplication;
5import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6
7@SpringBootApplication
8@EnableEurekaClient
9public class ApiGatewayApplication {
10
11    public static void main(String[] args) {
12        SpringApplication.run(ApiGatewayApplication.class, args);
13    }
14
15}
16

application.yml

1package com.sample.apigateway;
2
3import org.springframework.boot.SpringApplication;
4import org.springframework.boot.autoconfigure.SpringBootApplication;
5import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6
7@SpringBootApplication
8@EnableEurekaClient
9public class ApiGatewayApplication {
10
11    public static void main(String[] args) {
12        SpringApplication.run(ApiGatewayApplication.class, args);
13    }
14
15}
16spring:
17  application:
18    name: GATEWAY-SERVICE
19
20  cloud:
21    gateway:
22      routes:
23        - id: USER-SERVICE
24          uri: lb://USER-SERVICE
25          predicates:
26            - Path=/users/**
27        - id: DEPARTMENT-SERVICE
28          uri: lb://DEPARTMENT-SERVICE
29          predicates:
30            - Path=/departments/**
31
32eureka:
33  client:
34    register-with-eureka: true
35    fetch-registry: true
36    service-url:
37      defaultZone: http://localhost:8761/eureka/
38
39  instance:
40    hostname: localhost
41
42server:
43  port: 9191
44

pom.xml

1package com.sample.apigateway;
2
3import org.springframework.boot.SpringApplication;
4import org.springframework.boot.autoconfigure.SpringBootApplication;
5import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6
7@SpringBootApplication
8@EnableEurekaClient
9public class ApiGatewayApplication {
10
11    public static void main(String[] args) {
12        SpringApplication.run(ApiGatewayApplication.class, args);
13    }
14
15}
16spring:
17  application:
18    name: GATEWAY-SERVICE
19
20  cloud:
21    gateway:
22      routes:
23        - id: USER-SERVICE
24          uri: lb://USER-SERVICE
25          predicates:
26            - Path=/users/**
27        - id: DEPARTMENT-SERVICE
28          uri: lb://DEPARTMENT-SERVICE
29          predicates:
30            - Path=/departments/**
31
32eureka:
33  client:
34    register-with-eureka: true
35    fetch-registry: true
36    service-url:
37      defaultZone: http://localhost:8761/eureka/
38
39  instance:
40    hostname: localhost
41
42server:
43  port: 9191
44<?xml version="1.0" encoding="UTF-8"?>
45<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
46         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
47    <modelVersion>4.0.0</modelVersion>
48    <parent>
49        <groupId>org.springframework.boot</groupId>
50        <artifactId>spring-boot-starter-parent</artifactId>
51        <version>2.5.3</version>
52        <relativePath/> <!-- lookup parent from repository -->
53    </parent>
54    <groupId>com.sample.apigateway</groupId>
55    <artifactId>apigateway</artifactId>
56    <version>0.0.1-SNAPSHOT</version>
57    <name>apigateway</name>
58    <description>Demo project for Spring Boot</description>
59    <properties>
60        <java.version>11</java.version>
61        <spring-cloud.version>2020.0.3</spring-cloud.version>
62    </properties>
63    <dependencies>
64        <dependency>
65            <groupId>org.springframework.boot</groupId>
66            <artifactId>spring-boot-starter-actuator</artifactId>
67        </dependency>
68        <dependency>
69            <groupId>org.springframework.boot</groupId>
70            <artifactId>spring-boot-starter-webflux</artifactId>
71        </dependency>
72        <dependency>
73            <groupId>io.springfox</groupId>
74            <artifactId>springfox-boot-starter</artifactId>
75            <version>3.0.0</version>
76        </dependency>
77        <dependency>
78            <groupId>org.springframework.cloud</groupId>
79            <artifactId>spring-cloud-starter-gateway</artifactId>
80        </dependency>
81        <dependency>
82            <groupId>org.springframework.cloud</groupId>
83            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
84        </dependency>
85        <dependency>
86            <groupId>org.springframework.cloud</groupId>
87            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
88        </dependency>
89
90        <dependency>
91            <groupId>org.springframework.boot</groupId>
92            <artifactId>spring-boot-starter-test</artifactId>
93            <scope>test</scope>
94        </dependency>
95    </dependencies>
96    <dependencyManagement>
97        <dependencies>
98            <dependency>
99                <groupId>org.springframework.cloud</groupId>
100                <artifactId>spring-cloud-dependencies</artifactId>
101                <version>${spring-cloud.version}</version>
102                <type>pom</type>
103                <scope>import</scope>
104            </dependency>
105        </dependencies>
106    </dependencyManagement>
107
108    <build>
109        <plugins>
110            <plugin>
111                <groupId>org.springframework.boot</groupId>
112                <artifactId>spring-boot-maven-plugin</artifactId>
113            </plugin>
114        </plugins>
115    </build>
116
117</project>
118

Full Error Message

1package com.sample.apigateway;
2
3import org.springframework.boot.SpringApplication;
4import org.springframework.boot.autoconfigure.SpringBootApplication;
5import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6
7@SpringBootApplication
8@EnableEurekaClient
9public class ApiGatewayApplication {
10
11    public static void main(String[] args) {
12        SpringApplication.run(ApiGatewayApplication.class, args);
13    }
14
15}
16spring:
17  application:
18    name: GATEWAY-SERVICE
19
20  cloud:
21    gateway:
22      routes:
23        - id: USER-SERVICE
24          uri: lb://USER-SERVICE
25          predicates:
26            - Path=/users/**
27        - id: DEPARTMENT-SERVICE
28          uri: lb://DEPARTMENT-SERVICE
29          predicates:
30            - Path=/departments/**
31
32eureka:
33  client:
34    register-with-eureka: true
35    fetch-registry: true
36    service-url:
37      defaultZone: http://localhost:8761/eureka/
38
39  instance:
40    hostname: localhost
41
42server:
43  port: 9191
44<?xml version="1.0" encoding="UTF-8"?>
45<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
46         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
47    <modelVersion>4.0.0</modelVersion>
48    <parent>
49        <groupId>org.springframework.boot</groupId>
50        <artifactId>spring-boot-starter-parent</artifactId>
51        <version>2.5.3</version>
52        <relativePath/> <!-- lookup parent from repository -->
53    </parent>
54    <groupId>com.sample.apigateway</groupId>
55    <artifactId>apigateway</artifactId>
56    <version>0.0.1-SNAPSHOT</version>
57    <name>apigateway</name>
58    <description>Demo project for Spring Boot</description>
59    <properties>
60        <java.version>11</java.version>
61        <spring-cloud.version>2020.0.3</spring-cloud.version>
62    </properties>
63    <dependencies>
64        <dependency>
65            <groupId>org.springframework.boot</groupId>
66            <artifactId>spring-boot-starter-actuator</artifactId>
67        </dependency>
68        <dependency>
69            <groupId>org.springframework.boot</groupId>
70            <artifactId>spring-boot-starter-webflux</artifactId>
71        </dependency>
72        <dependency>
73            <groupId>io.springfox</groupId>
74            <artifactId>springfox-boot-starter</artifactId>
75            <version>3.0.0</version>
76        </dependency>
77        <dependency>
78            <groupId>org.springframework.cloud</groupId>
79            <artifactId>spring-cloud-starter-gateway</artifactId>
80        </dependency>
81        <dependency>
82            <groupId>org.springframework.cloud</groupId>
83            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
84        </dependency>
85        <dependency>
86            <groupId>org.springframework.cloud</groupId>
87            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
88        </dependency>
89
90        <dependency>
91            <groupId>org.springframework.boot</groupId>
92            <artifactId>spring-boot-starter-test</artifactId>
93            <scope>test</scope>
94        </dependency>
95    </dependencies>
96    <dependencyManagement>
97        <dependencies>
98            <dependency>
99                <groupId>org.springframework.cloud</groupId>
100                <artifactId>spring-cloud-dependencies</artifactId>
101                <version>${spring-cloud.version}</version>
102                <type>pom</type>
103                <scope>import</scope>
104            </dependency>
105        </dependencies>
106    </dependencyManagement>
107
108    <build>
109        <plugins>
110            <plugin>
111                <groupId>org.springframework.boot</groupId>
112                <artifactId>spring-boot-maven-plugin</artifactId>
113            </plugin>
114        </plugins>
115    </build>
116
117</project>
1182021-07-30 23:12:02.420  WARN 19032 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration$SpringMvcFoundOnClasspathConfiguration': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration$SpringMvcFoundOnClasspathConfiguration]: Constructor threw exception; nested exception is org.springframework.cloud.gateway.support.MvcFoundOnClasspathException
1192021-07-30 23:12:02.423  INFO 19032 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
1202021-07-30 23:12:02.441  INFO 19032 --- [           main] ConditionEvaluationReportLoggingListener : 
121
122Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
1232021-07-30 23:12:02.454 ERROR 19032 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
124
125***************************
126APPLICATION FAILED TO START
127***************************
128
129Description:
130
131Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.
132
133Action:
134
135Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.
136
137
138Process finished with exit code 1
139

ANSWER

Answered 2021-Aug-01 at 06:17

Please note that Spring Cloud Gateway is not compatible with Spring MVC (spring-boot-starter-web). This is outlined in section "How to include Spring Cloud Gateway in the official reference documentation":

Spring Cloud Gateway is built on Spring Boot 2.x, Spring WebFlux, and Project Reactor. As a consequence, many of the familiar synchronous libraries (Spring Data and Spring Security, for example) and patterns you know may not apply when you use Spring Cloud Gateway.

Additionally, it is stated that:

Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux. It does not work in a traditional Servlet Container or when built as a WAR.

As already suggested by the error message, you would need to remove the dependency on spring-boot-starter-web. You can list all your direct and transitive dependencies with the following command:

1package com.sample.apigateway;
2
3import org.springframework.boot.SpringApplication;
4import org.springframework.boot.autoconfigure.SpringBootApplication;
5import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6
7@SpringBootApplication
8@EnableEurekaClient
9public class ApiGatewayApplication {
10
11    public static void main(String[] args) {
12        SpringApplication.run(ApiGatewayApplication.class, args);
13    }
14
15}
16spring:
17  application:
18    name: GATEWAY-SERVICE
19
20  cloud:
21    gateway:
22      routes:
23        - id: USER-SERVICE
24          uri: lb://USER-SERVICE
25          predicates:
26            - Path=/users/**
27        - id: DEPARTMENT-SERVICE
28          uri: lb://DEPARTMENT-SERVICE
29          predicates:
30            - Path=/departments/**
31
32eureka:
33  client:
34    register-with-eureka: true
35    fetch-registry: true
36    service-url:
37      defaultZone: http://localhost:8761/eureka/
38
39  instance:
40    hostname: localhost
41
42server:
43  port: 9191
44<?xml version="1.0" encoding="UTF-8"?>
45<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
46         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
47    <modelVersion>4.0.0</modelVersion>
48    <parent>
49        <groupId>org.springframework.boot</groupId>
50        <artifactId>spring-boot-starter-parent</artifactId>
51        <version>2.5.3</version>
52        <relativePath/> <!-- lookup parent from repository -->
53    </parent>
54    <groupId>com.sample.apigateway</groupId>
55    <artifactId>apigateway</artifactId>
56    <version>0.0.1-SNAPSHOT</version>
57    <name>apigateway</name>
58    <description>Demo project for Spring Boot</description>
59    <properties>
60        <java.version>11</java.version>
61        <spring-cloud.version>2020.0.3</spring-cloud.version>
62    </properties>
63    <dependencies>
64        <dependency>
65            <groupId>org.springframework.boot</groupId>
66            <artifactId>spring-boot-starter-actuator</artifactId>
67        </dependency>
68        <dependency>
69            <groupId>org.springframework.boot</groupId>
70            <artifactId>spring-boot-starter-webflux</artifactId>
71        </dependency>
72        <dependency>
73            <groupId>io.springfox</groupId>
74            <artifactId>springfox-boot-starter</artifactId>
75            <version>3.0.0</version>
76        </dependency>
77        <dependency>
78            <groupId>org.springframework.cloud</groupId>
79            <artifactId>spring-cloud-starter-gateway</artifactId>
80        </dependency>
81        <dependency>
82            <groupId>org.springframework.cloud</groupId>
83            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
84        </dependency>
85        <dependency>
86            <groupId>org.springframework.cloud</groupId>
87            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
88        </dependency>
89
90        <dependency>
91            <groupId>org.springframework.boot</groupId>
92            <artifactId>spring-boot-starter-test</artifactId>
93            <scope>test</scope>
94        </dependency>
95    </dependencies>
96    <dependencyManagement>
97        <dependencies>
98            <dependency>
99                <groupId>org.springframework.cloud</groupId>
100                <artifactId>spring-cloud-dependencies</artifactId>
101                <version>${spring-cloud.version}</version>
102                <type>pom</type>
103                <scope>import</scope>
104            </dependency>
105        </dependencies>
106    </dependencyManagement>
107
108    <build>
109        <plugins>
110            <plugin>
111                <groupId>org.springframework.boot</groupId>
112                <artifactId>spring-boot-maven-plugin</artifactId>
113            </plugin>
114        </plugins>
115    </build>
116
117</project>
1182021-07-30 23:12:02.420  WARN 19032 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration$SpringMvcFoundOnClasspathConfiguration': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration$SpringMvcFoundOnClasspathConfiguration]: Constructor threw exception; nested exception is org.springframework.cloud.gateway.support.MvcFoundOnClasspathException
1192021-07-30 23:12:02.423  INFO 19032 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
1202021-07-30 23:12:02.441  INFO 19032 --- [           main] ConditionEvaluationReportLoggingListener : 
121
122Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
1232021-07-30 23:12:02.454 ERROR 19032 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
124
125***************************
126APPLICATION FAILED TO START
127***************************
128
129Description:
130
131Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.
132
133Action:
134
135Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.
136
137
138Process finished with exit code 1
139mvn dependency:tree
140

This will reveal that spring-cloud-starter-netflix-eureka-server depends on spring-boot-starter-web. Once you remove the following lines from your pom.xml, your application should start up:

1package com.sample.apigateway;
2
3import org.springframework.boot.SpringApplication;
4import org.springframework.boot.autoconfigure.SpringBootApplication;
5import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6
7@SpringBootApplication
8@EnableEurekaClient
9public class ApiGatewayApplication {
10
11    public static void main(String[] args) {
12        SpringApplication.run(ApiGatewayApplication.class, args);
13    }
14
15}
16spring:
17  application:
18    name: GATEWAY-SERVICE
19
20  cloud:
21    gateway:
22      routes:
23        - id: USER-SERVICE
24          uri: lb://USER-SERVICE
25          predicates:
26            - Path=/users/**
27        - id: DEPARTMENT-SERVICE
28          uri: lb://DEPARTMENT-SERVICE
29          predicates:
30            - Path=/departments/**
31
32eureka:
33  client:
34    register-with-eureka: true
35    fetch-registry: true
36    service-url:
37      defaultZone: http://localhost:8761/eureka/
38
39  instance:
40    hostname: localhost
41
42server:
43  port: 9191
44<?xml version="1.0" encoding="UTF-8"?>
45<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
46         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
47    <modelVersion>4.0.0</modelVersion>
48    <parent>
49        <groupId>org.springframework.boot</groupId>
50        <artifactId>spring-boot-starter-parent</artifactId>
51        <version>2.5.3</version>
52        <relativePath/> <!-- lookup parent from repository -->
53    </parent>
54    <groupId>com.sample.apigateway</groupId>
55    <artifactId>apigateway</artifactId>
56    <version>0.0.1-SNAPSHOT</version>
57    <name>apigateway</name>
58    <description>Demo project for Spring Boot</description>
59    <properties>
60        <java.version>11</java.version>
61        <spring-cloud.version>2020.0.3</spring-cloud.version>
62    </properties>
63    <dependencies>
64        <dependency>
65            <groupId>org.springframework.boot</groupId>
66            <artifactId>spring-boot-starter-actuator</artifactId>
67        </dependency>
68        <dependency>
69            <groupId>org.springframework.boot</groupId>
70            <artifactId>spring-boot-starter-webflux</artifactId>
71        </dependency>
72        <dependency>
73            <groupId>io.springfox</groupId>
74            <artifactId>springfox-boot-starter</artifactId>
75            <version>3.0.0</version>
76        </dependency>
77        <dependency>
78            <groupId>org.springframework.cloud</groupId>
79            <artifactId>spring-cloud-starter-gateway</artifactId>
80        </dependency>
81        <dependency>
82            <groupId>org.springframework.cloud</groupId>
83            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
84        </dependency>
85        <dependency>
86            <groupId>org.springframework.cloud</groupId>
87            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
88        </dependency>
89
90        <dependency>
91            <groupId>org.springframework.boot</groupId>
92            <artifactId>spring-boot-starter-test</artifactId>
93            <scope>test</scope>
94        </dependency>
95    </dependencies>
96    <dependencyManagement>
97        <dependencies>
98            <dependency>
99                <groupId>org.springframework.cloud</groupId>
100                <artifactId>spring-cloud-dependencies</artifactId>
101                <version>${spring-cloud.version}</version>
102                <type>pom</type>
103                <scope>import</scope>
104            </dependency>
105        </dependencies>
106    </dependencyManagement>
107
108    <build>
109        <plugins>
110            <plugin>
111                <groupId>org.springframework.boot</groupId>
112                <artifactId>spring-boot-maven-plugin</artifactId>
113            </plugin>
114        </plugins>
115    </build>
116
117</project>
1182021-07-30 23:12:02.420  WARN 19032 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration$SpringMvcFoundOnClasspathConfiguration': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration$SpringMvcFoundOnClasspathConfiguration]: Constructor threw exception; nested exception is org.springframework.cloud.gateway.support.MvcFoundOnClasspathException
1192021-07-30 23:12:02.423  INFO 19032 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
1202021-07-30 23:12:02.441  INFO 19032 --- [           main] ConditionEvaluationReportLoggingListener : 
121
122Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
1232021-07-30 23:12:02.454 ERROR 19032 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
124
125***************************
126APPLICATION FAILED TO START
127***************************
128
129Description:
130
131Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.
132
133Action:
134
135Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.
136
137
138Process finished with exit code 1
139mvn dependency:tree
140<dependency>
141    <groupId>org.springframework.cloud</groupId>
142    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
143</dependency>
144

Source https://stackoverflow.com/questions/68587832

QUESTION

Springfox 3.0.0 is not working with Spring Boot 2.6.0

Asked 2022-Feb-22 at 14:10

Springfox 3.0.0 is not working with Spring Boot 2.6.0, after upgrading I am getting the following error

1org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
2    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
3    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
4    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
5    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
6    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
7    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
8    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
9    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
10    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
11    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
12    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
13    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
14    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
15    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
16    at com.enkindle.AntivirusApplication.main(AntivirusApplication.java:16)
17    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
19    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
20    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
21    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
22Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
23    at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56)
24    at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113)
25    at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89)
26    at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:473)
27    at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
28    at java.base/java.util.TimSort.sort(TimSort.java:234)
29    at java.base/java.util.Arrays.sort(Arrays.java:1307)
30    at java.base/java.util.ArrayList.sort(ArrayList.java:1721)
31    at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:392)
32    at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
33    at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
34    at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
35    at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
36    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
37    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
38    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
39    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
40    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
41    at springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider.requestHandlers(WebMvcRequestHandlerProvider.java:81)
42    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
43    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
44    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
45    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
46    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
47    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
48    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
49    at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.withDefaults(AbstractDocumentationPluginsBootstrapper.java:107)
50    at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.buildContext(AbstractDocumentationPluginsBootstrapper.java:91)
51    at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82)
52    at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100)
53    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
54    ... 19 common frames omitted
55

ANSWER

Answered 2021-Dec-01 at 02:17

I know this does not solve your problem directly, but consider moving to springdoc which most recent release supports Spring Boot 2.6.0. Springfox is so buggy at this point that is a pain to use. I've moved to springdoc 2 years ago because of its Spring WebFlux support and I am very happy about it. Additionally, it also supports Kotlin Coroutines, which I am not sure Springfox does.

If you decide to migrate, springdoc even has a migration guide.

Source https://stackoverflow.com/questions/70178343

QUESTION

Spring Boot WebClient stops sending requests

Asked 2022-Feb-18 at 14:42

I am running a Spring Boot app that uses WebClient for both non-blocking and blocking HTTP requests. After the app has run for some time, all outgoing HTTP requests seem to get stuck.

WebClient is used to send requests to multiple hosts, but as an example, here is how it is initialized and used to send requests to Telegram:

WebClientConfig:

1    @Bean
2    public ReactorClientHttpConnector httpClient() {
3        HttpClient.create(ConnectionProvider.builder("connectionProvider").build())
4                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
5                .responseTimeout(Duration.ofMillis(responseTimeout));
6        return new ReactorClientHttpConnector(httpClient);
7    }
8

The same ReactorClientHttpConnector is used for all WebClients.

TelegramClient:

1    @Bean
2    public ReactorClientHttpConnector httpClient() {
3        HttpClient.create(ConnectionProvider.builder("connectionProvider").build())
4                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
5                .responseTimeout(Duration.ofMillis(responseTimeout));
6        return new ReactorClientHttpConnector(httpClient);
7    }
8    @Autowired
9    ReactorClientHttpConnector httpClient;
10
11    WebClient webClient;
12
13    RateLimiter rateLimiter;
14
15    @PostConstruct
16    public void init() {
17        webClient = WebClient.builder()
18                .clientConnector(httpClient)
19                .baseUrl(telegramUrl)
20                .build();
21
22        rateLimiter = RateLimiter.of("telegram-rate-limiter",
23                RateLimiterConfig.custom()
24                        .limitRefreshPeriod(Duration.ofMinutes(1))
25                        .limitForPeriod(20)
26                        .build());
27    }
28
29    public void sendMessage(@PathVariable("token") String token, @RequestParam("chat_id") long chatId, @RequestParam("text") String message) {
30        webClient.post().uri(String.format("/bot%s/sendMessage", token))
31                .contentType(MediaType.APPLICATION_JSON)
32                .body(BodyInserters.fromFormData("chat_id", String.valueOf(chatId))
33                        .with("text", message))
34                .retrieve()
35                .bodyToMono(Void.class)
36                .transformDeferred(RateLimiterOperator.of(rateLimiter))
37                .block();
38    }
39

The RateLimiter is used to ensure the number of requests does not exceed 20 a minute as specified in the Telegram API.

When the app is started, all requests are resolved normally as expected. But after some time has passed, all requests seem to get stuck. The amount of time needed for this to happen can vary from a few hours to a few days. It happens for all requests to different hosts and is easily noticeable when messages from the TelegramBot stops. Once the requests get stuck, they are stuck indefinitely and I have to restart the app to get it working again.

There are no exceptions in the log that seem to have caused this. Since I maintain a queue for my telegram messages, I can see the point in time when the requests stop when the number of messages in the queue steadily increases and when errors happen in the other processes that are waiting for the requests to resolve.

It does not seem like the requests are even sent out as the connect timeout and response timeout that I have set do not take effect.

I had previously also tried setting idle time to 0 but that did not solve the problem

1    @Bean
2    public ReactorClientHttpConnector httpClient() {
3        HttpClient.create(ConnectionProvider.builder("connectionProvider").build())
4                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
5                .responseTimeout(Duration.ofMillis(responseTimeout));
6        return new ReactorClientHttpConnector(httpClient);
7    }
8    @Autowired
9    ReactorClientHttpConnector httpClient;
10
11    WebClient webClient;
12
13    RateLimiter rateLimiter;
14
15    @PostConstruct
16    public void init() {
17        webClient = WebClient.builder()
18                .clientConnector(httpClient)
19                .baseUrl(telegramUrl)
20                .build();
21
22        rateLimiter = RateLimiter.of("telegram-rate-limiter",
23                RateLimiterConfig.custom()
24                        .limitRefreshPeriod(Duration.ofMinutes(1))
25                        .limitForPeriod(20)
26                        .build());
27    }
28
29    public void sendMessage(@PathVariable("token") String token, @RequestParam("chat_id") long chatId, @RequestParam("text") String message) {
30        webClient.post().uri(String.format("/bot%s/sendMessage", token))
31                .contentType(MediaType.APPLICATION_JSON)
32                .body(BodyInserters.fromFormData("chat_id", String.valueOf(chatId))
33                        .with("text", message))
34                .retrieve()
35                .bodyToMono(Void.class)
36                .transformDeferred(RateLimiterOperator.of(rateLimiter))
37                .block();
38    }
39    @Bean
40    public ReactorClientHttpConnector httpClient() {
41        HttpClient httpClient = HttpClient.create(ConnectionProvider.builder("connectionProvider").maxConnections(1000).maxIdleTime(Duration.ofSeconds(0)).build())
42        HttpClient httpClient = HttpClient.newConnection()
43                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
44                .responseTimeout(Duration.ofMillis(responseTimeout));
45        return new ReactorClientHttpConnector(httpClient);
46    }
47

Update:

I enabled metrics and viewed it using micrometer when it got stuck. Interestingly, it shows that there is one connection for Telegram, but also shows no connections on idle, pending or active.

1    @Bean
2    public ReactorClientHttpConnector httpClient() {
3        HttpClient.create(ConnectionProvider.builder("connectionProvider").build())
4                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
5                .responseTimeout(Duration.ofMillis(responseTimeout));
6        return new ReactorClientHttpConnector(httpClient);
7    }
8    @Autowired
9    ReactorClientHttpConnector httpClient;
10
11    WebClient webClient;
12
13    RateLimiter rateLimiter;
14
15    @PostConstruct
16    public void init() {
17        webClient = WebClient.builder()
18                .clientConnector(httpClient)
19                .baseUrl(telegramUrl)
20                .build();
21
22        rateLimiter = RateLimiter.of("telegram-rate-limiter",
23                RateLimiterConfig.custom()
24                        .limitRefreshPeriod(Duration.ofMinutes(1))
25                        .limitForPeriod(20)
26                        .build());
27    }
28
29    public void sendMessage(@PathVariable("token") String token, @RequestParam("chat_id") long chatId, @RequestParam("text") String message) {
30        webClient.post().uri(String.format("/bot%s/sendMessage", token))
31                .contentType(MediaType.APPLICATION_JSON)
32                .body(BodyInserters.fromFormData("chat_id", String.valueOf(chatId))
33                        .with("text", message))
34                .retrieve()
35                .bodyToMono(Void.class)
36                .transformDeferred(RateLimiterOperator.of(rateLimiter))
37                .block();
38    }
39    @Bean
40    public ReactorClientHttpConnector httpClient() {
41        HttpClient httpClient = HttpClient.create(ConnectionProvider.builder("connectionProvider").maxConnections(1000).maxIdleTime(Duration.ofSeconds(0)).build())
42        HttpClient httpClient = HttpClient.newConnection()
43                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
44                .responseTimeout(Duration.ofMillis(responseTimeout));
45        return new ReactorClientHttpConnector(httpClient);
46    }
47reactor_netty_connection_provider_idle_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
48reactor_netty_connection_provider_pending_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
49reactor_netty_connection_provider_active_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
50reactor_netty_connection_provider_total_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 1.0
51

Could the issue be this missing connection?

Update 2:

I thought this might be related to this other issue: Closing Reactor Netty connection on error status codes

So I updated my HttpClient to this:

1    @Bean
2    public ReactorClientHttpConnector httpClient() {
3        HttpClient.create(ConnectionProvider.builder("connectionProvider").build())
4                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
5                .responseTimeout(Duration.ofMillis(responseTimeout));
6        return new ReactorClientHttpConnector(httpClient);
7    }
8    @Autowired
9    ReactorClientHttpConnector httpClient;
10
11    WebClient webClient;
12
13    RateLimiter rateLimiter;
14
15    @PostConstruct
16    public void init() {
17        webClient = WebClient.builder()
18                .clientConnector(httpClient)
19                .baseUrl(telegramUrl)
20                .build();
21
22        rateLimiter = RateLimiter.of("telegram-rate-limiter",
23                RateLimiterConfig.custom()
24                        .limitRefreshPeriod(Duration.ofMinutes(1))
25                        .limitForPeriod(20)
26                        .build());
27    }
28
29    public void sendMessage(@PathVariable("token") String token, @RequestParam("chat_id") long chatId, @RequestParam("text") String message) {
30        webClient.post().uri(String.format("/bot%s/sendMessage", token))
31                .contentType(MediaType.APPLICATION_JSON)
32                .body(BodyInserters.fromFormData("chat_id", String.valueOf(chatId))
33                        .with("text", message))
34                .retrieve()
35                .bodyToMono(Void.class)
36                .transformDeferred(RateLimiterOperator.of(rateLimiter))
37                .block();
38    }
39    @Bean
40    public ReactorClientHttpConnector httpClient() {
41        HttpClient httpClient = HttpClient.create(ConnectionProvider.builder("connectionProvider").maxConnections(1000).maxIdleTime(Duration.ofSeconds(0)).build())
42        HttpClient httpClient = HttpClient.newConnection()
43                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
44                .responseTimeout(Duration.ofMillis(responseTimeout));
45        return new ReactorClientHttpConnector(httpClient);
46    }
47reactor_netty_connection_provider_idle_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
48reactor_netty_connection_provider_pending_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
49reactor_netty_connection_provider_active_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
50reactor_netty_connection_provider_total_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 1.0
51    @Bean
52    public ReactorClientHttpConnector httpClient() {
53        HttpClient httpClient = HttpClient.create(ConnectionProvider.builder("connectionProvider").metrics(true).build())
54                .doAfterResponseSuccess((r, c) -> c.dispose())
55                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
56                .responseTimeout(Duration.ofMillis(responseTimeout));
57        return new ReactorClientHttpConnector(httpClient);
58    }
59

But all that seemed to do is accelerate the occurrence of the problem. Just like before, the active, pending and idle connections do not add up to the total connections. The total is always greater than the other 3 metrics added together.

Update 3: I did a thread dump when the issue happened. There were a total of 74 threads, so I don't think the app is running out of threads.

The dump for the Telegram thread:

1    @Bean
2    public ReactorClientHttpConnector httpClient() {
3        HttpClient.create(ConnectionProvider.builder("connectionProvider").build())
4                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
5                .responseTimeout(Duration.ofMillis(responseTimeout));
6        return new ReactorClientHttpConnector(httpClient);
7    }
8    @Autowired
9    ReactorClientHttpConnector httpClient;
10
11    WebClient webClient;
12
13    RateLimiter rateLimiter;
14
15    @PostConstruct
16    public void init() {
17        webClient = WebClient.builder()
18                .clientConnector(httpClient)
19                .baseUrl(telegramUrl)
20                .build();
21
22        rateLimiter = RateLimiter.of("telegram-rate-limiter",
23                RateLimiterConfig.custom()
24                        .limitRefreshPeriod(Duration.ofMinutes(1))
25                        .limitForPeriod(20)
26                        .build());
27    }
28
29    public void sendMessage(@PathVariable("token") String token, @RequestParam("chat_id") long chatId, @RequestParam("text") String message) {
30        webClient.post().uri(String.format("/bot%s/sendMessage", token))
31                .contentType(MediaType.APPLICATION_JSON)
32                .body(BodyInserters.fromFormData("chat_id", String.valueOf(chatId))
33                        .with("text", message))
34                .retrieve()
35                .bodyToMono(Void.class)
36                .transformDeferred(RateLimiterOperator.of(rateLimiter))
37                .block();
38    }
39    @Bean
40    public ReactorClientHttpConnector httpClient() {
41        HttpClient httpClient = HttpClient.create(ConnectionProvider.builder("connectionProvider").maxConnections(1000).maxIdleTime(Duration.ofSeconds(0)).build())
42        HttpClient httpClient = HttpClient.newConnection()
43                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
44                .responseTimeout(Duration.ofMillis(responseTimeout));
45        return new ReactorClientHttpConnector(httpClient);
46    }
47reactor_netty_connection_provider_idle_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
48reactor_netty_connection_provider_pending_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
49reactor_netty_connection_provider_active_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
50reactor_netty_connection_provider_total_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 1.0
51    @Bean
52    public ReactorClientHttpConnector httpClient() {
53        HttpClient httpClient = HttpClient.create(ConnectionProvider.builder("connectionProvider").metrics(true).build())
54                .doAfterResponseSuccess((r, c) -> c.dispose())
55                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
56                .responseTimeout(Duration.ofMillis(responseTimeout));
57        return new ReactorClientHttpConnector(httpClient);
58    }
59"TelegramBot" #20 daemon prio=5 os_prio=0 cpu=14.65ms elapsed=47154.24s tid=0x00007f6b28e73000 nid=0x1c waiting on condition  [0x00007f6aed6fb000]
60   java.lang.Thread.State: WAITING (parking)
61        at jdk.internal.misc.Unsafe.park(java.base@11.0.13/Native Method)
62        - parking to wait for  <0x00000000fa865c80> (a java.util.concurrent.CountDownLatch$Sync)
63        at java.util.concurrent.locks.LockSupport.park(java.base@11.0.13/LockSupport.java:194)
64        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(java.base@11.0.13/AbstractQueuedSynchronizer.java:885)
65        at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(java.base@11.0.13/AbstractQueuedSynchronizer.java:1039)
66        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(java.base@11.0.13/AbstractQueuedSynchronizer.java:1345)
67        at java.util.concurrent.CountDownLatch.await(java.base@11.0.13/CountDownLatch.java:232)
68        at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:87)
69        at reactor.core.publisher.Mono.block(Mono.java:1707)
70        at com.moon.arbitrage.cm.feign.TelegramClient.sendMessage(TelegramClient.java:59)
71        at com.moon.arbitrage.cm.service.TelegramService.lambda$sendArbMessage$0(TelegramService.java:53)
72        at com.moon.arbitrage.cm.service.TelegramService$$Lambda$1092/0x000000084070f840.run(Unknown Source)
73        at com.moon.arbitrage.cm.service.TelegramService.task(TelegramService.java:82)
74        at com.moon.arbitrage.cm.service.TelegramService$$Lambda$920/0x0000000840665040.run(Unknown Source)
75        at java.lang.Thread.run(java.base@11.0.13/Thread.java:829)
76
77   Locked ownable synchronizers:
78        - None
79

The reactor worker threads:

1    @Bean
2    public ReactorClientHttpConnector httpClient() {
3        HttpClient.create(ConnectionProvider.builder("connectionProvider").build())
4                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
5                .responseTimeout(Duration.ofMillis(responseTimeout));
6        return new ReactorClientHttpConnector(httpClient);
7    }
8    @Autowired
9    ReactorClientHttpConnector httpClient;
10
11    WebClient webClient;
12
13    RateLimiter rateLimiter;
14
15    @PostConstruct
16    public void init() {
17        webClient = WebClient.builder()
18                .clientConnector(httpClient)
19                .baseUrl(telegramUrl)
20                .build();
21
22        rateLimiter = RateLimiter.of("telegram-rate-limiter",
23                RateLimiterConfig.custom()
24                        .limitRefreshPeriod(Duration.ofMinutes(1))
25                        .limitForPeriod(20)
26                        .build());
27    }
28
29    public void sendMessage(@PathVariable("token") String token, @RequestParam("chat_id") long chatId, @RequestParam("text") String message) {
30        webClient.post().uri(String.format("/bot%s/sendMessage", token))
31                .contentType(MediaType.APPLICATION_JSON)
32                .body(BodyInserters.fromFormData("chat_id", String.valueOf(chatId))
33                        .with("text", message))
34                .retrieve()
35                .bodyToMono(Void.class)
36                .transformDeferred(RateLimiterOperator.of(rateLimiter))
37                .block();
38    }
39    @Bean
40    public ReactorClientHttpConnector httpClient() {
41        HttpClient httpClient = HttpClient.create(ConnectionProvider.builder("connectionProvider").maxConnections(1000).maxIdleTime(Duration.ofSeconds(0)).build())
42        HttpClient httpClient = HttpClient.newConnection()
43                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
44                .responseTimeout(Duration.ofMillis(responseTimeout));
45        return new ReactorClientHttpConnector(httpClient);
46    }
47reactor_netty_connection_provider_idle_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
48reactor_netty_connection_provider_pending_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
49reactor_netty_connection_provider_active_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 0.0
50reactor_netty_connection_provider_total_connections{id="-1268283746",name="connectionProvider",remote_address="api.telegram.org:443",} 1.0
51    @Bean
52    public ReactorClientHttpConnector httpClient() {
53        HttpClient httpClient = HttpClient.create(ConnectionProvider.builder("connectionProvider").metrics(true).build())
54                .doAfterResponseSuccess((r, c) -> c.dispose())
55                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
56                .responseTimeout(Duration.ofMillis(responseTimeout));
57        return new ReactorClientHttpConnector(httpClient);
58    }
59"TelegramBot" #20 daemon prio=5 os_prio=0 cpu=14.65ms elapsed=47154.24s tid=0x00007f6b28e73000 nid=0x1c waiting on condition  [0x00007f6aed6fb000]
60   java.lang.Thread.State: WAITING (parking)
61        at jdk.internal.misc.Unsafe.park(java.base@11.0.13/Native Method)
62        - parking to wait for  <0x00000000fa865c80> (a java.util.concurrent.CountDownLatch$Sync)
63        at java.util.concurrent.locks.LockSupport.park(java.base@11.0.13/LockSupport.java:194)
64        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(java.base@11.0.13/AbstractQueuedSynchronizer.java:885)
65        at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(java.base@11.0.13/AbstractQueuedSynchronizer.java:1039)
66        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(java.base@11.0.13/AbstractQueuedSynchronizer.java:1345)
67        at java.util.concurrent.CountDownLatch.await(java.base@11.0.13/CountDownLatch.java:232)
68        at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:87)
69        at reactor.core.publisher.Mono.block(Mono.java:1707)
70        at com.moon.arbitrage.cm.feign.TelegramClient.sendMessage(TelegramClient.java:59)
71        at com.moon.arbitrage.cm.service.TelegramService.lambda$sendArbMessage$0(TelegramService.java:53)
72        at com.moon.arbitrage.cm.service.TelegramService$$Lambda$1092/0x000000084070f840.run(Unknown Source)
73        at com.moon.arbitrage.cm.service.TelegramService.task(TelegramService.java:82)
74        at com.moon.arbitrage.cm.service.TelegramService$$Lambda$920/0x0000000840665040.run(Unknown Source)
75        at java.lang.Thread.run(java.base@11.0.13/Thread.java:829)
76
77   Locked ownable synchronizers:
78        - None
79"reactor-http-epoll-1" #15 daemon prio=5 os_prio=0 cpu=810.44ms elapsed=47157.07s tid=0x00007f6b281c4000 nid=0x17 runnable  [0x00007f6b0c46c000]
80   java.lang.Thread.State: RUNNABLE
81        at io.netty.channel.epoll.Native.epollWait0(Native Method)
82        at io.netty.channel.epoll.Native.epollWait(Native.java:177)
83        at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:286)
84        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:351)
85        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
86        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
87        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
88        at java.lang.Thread.run(java.base@11.0.13/Thread.java:829)
89
90   Locked ownable synchronizers:
91        - None
92
93"reactor-http-epoll-2" #16 daemon prio=5 os_prio=0 cpu=1312.16ms elapsed=47157.07s tid=0x00007f6b281c5000 nid=0x18 waiting on condition  [0x00007f6b0c369000]
94   java.lang.Thread.State: WAITING (parking)
95        at jdk.internal.misc.Unsafe.park(java.base@11.0.13/Native Method)
96        - parking to wait for  <0x00000000fa865948> (a java.util.concurrent.CompletableFuture$Signaller)
97        at java.util.concurrent.locks.LockSupport.park(java.base@11.0.13/LockSupport.java:194)
98        at java.util.concurrent.CompletableFuture$Signaller.block(java.base@11.0.13/CompletableFuture.java:1796)
99        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@11.0.13/ForkJoinPool.java:3128)
100        at java.util.concurrent.CompletableFuture.waitingGet(java.base@11.0.13/CompletableFuture.java:1823)
101        at java.util.concurrent.CompletableFuture.get(java.base@11.0.13/CompletableFuture.java:1998)
102        at com.moon.arbitrage.cm.service.OrderService.reconcileOrder(OrderService.java:103)
103        at com.moon.arbitrage.cm.service.BotService$BotTask.lambda$task$1(BotService.java:383)
104        at com.moon.arbitrage.cm.service.BotService$BotTask$$Lambda$1161/0x00000008400af440.accept(Unknown Source)
105        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:171)
106        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)
107        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
108        at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:249)
109        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
110        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539)
111        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
112        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151)
113        at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107)
114        at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:295)
115        at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337)
116        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
117        at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:159)
118        at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:142)
119        at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260)
120        at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:142)
121        at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:400)
122        at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:419)
123        at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:473)
124        at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:702)
125        at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93)
126        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
127        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
128        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
129        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
130        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
131        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
132        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
133        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
134        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
135        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
136        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
137        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
138        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
139        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
140        at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1372)
141        at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1235)
142        at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1284)
143        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)
144        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446)
145        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
146        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
147        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
148        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
149        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
150        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
151        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
152        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
153        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
154        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
155        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
156        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
157        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
158        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
159        at java.lang.Thread.run(java.base@11.0.13/Thread.java:829)
160
161   Locked ownable synchronizers:
162        - None
163
164"reactor-http-epoll-3" #17 daemon prio=5 os_prio=0 cpu=171.84ms elapsed=47157.07s tid=0x00007f6b28beb000 nid=0x19 runnable  [0x00007f6b0c26a000]
165   java.lang.Thread.State: RUNNABLE
166        at io.netty.channel.epoll.Native.epollWait0(Native Method)
167        at io.netty.channel.epoll.Native.epollWait(Native.java:177)
168        at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:281)
169        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:351)
170        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
171        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
172        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
173        at java.lang.Thread.run(java.base@11.0.13/Thread.java:829)
174
175   Locked ownable synchronizers:
176        - None
177
178"reactor-http-epoll-4" #18 daemon prio=5 os_prio=0 cpu=188.10ms elapsed=47157.07s tid=0x00007f6b28b7d800 nid=0x1a runnable  [0x00007f6b0c169000]
179   java.lang.Thread.State: RUNNABLE
180        at io.netty.channel.epoll.Native.epollWait0(Native Method)
181        at io.netty.channel.epoll.Native.epollWait(Native.java:177)
182        at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:281)
183        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:351)
184        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
185        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
186        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
187        at java.lang.Thread.run(java.base@11.0.13/Thread.java:829)
188
189   Locked ownable synchronizers:
190        - None
191

Seems like one of them is blocked with another task (that isn't even from the Telegram service) but that shouldn't be an issue since the other three worker threads are runnable right?

ANSWER

Answered 2021-Dec-20 at 14:25

I would propose to take a look in the RateLimiter direction. Maybe it does not work as expected, depending on the number of requests your application does over time. From the Javadoc for Ratelimiter: "It is important to note that the number of permits requested never affects the throttling of the request itself ... but it affects the throttling of the next request. I.e., if an expensive task arrives at an idle RateLimiter, it will be granted immediately, but it is the next request that will experience extra throttling, thus paying for the cost of the expensive task." Also helpful might be this discussion: github or github

I could imaginge there is some throttling adding up or other effect in the RateLimiter, i would try to play around with it and make sure this thing really works the way you want. Alternatively, consider using Spring @Scheduled to read from your queue. You might want to spice it up using embedded JMS for further goodies (message persistence etc).

Source https://stackoverflow.com/questions/70357582

QUESTION

Java 17: Maven doesn't give much information about the error that happened, why?

Asked 2022-Feb-04 at 20:28

I'm upgrading from JDK 8 to JDK 17 and I'm trying to compile with mvn clean install -X -DskipTests and there's no information about the error.

Btw, I'm updating the dependencies and after that I compile to see if has errors. I need to update some dependencies such as Spring, Hibernate etc. I already updated Lombok.

I added the -X or -e option but I got the same result.

What can I do to get more information about the error? The log shows that it was loading hibernate-jpa-2.1-api before failed... so that means the problem is in this dependency?

1[INFO] [loading /Users/daniela/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar(/lombok/AllArgsConstructor$AnyAnnotation.class)]
2[INFO] [loading /Users/daniela/.m2/repository/org/ocpsoft/rewrite/rewrite-config-prettyfaces/2.0.4.Final/rewrite-config-prettyfaces-2.0.4.Final.jar(/com/ocpsoft/pretty/faces/annotation/URLValidator.class)]
3[INFO] [loading /Users/daniela/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar(/javax/servlet/annotation/WebInitParam.class)]
4[INFO] [loading /Users/daniela/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar(/lombok/RequiredArgsConstructor$AnyAnnotation.class)]
5[INFO] [loading /Users/daniela/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar(/javax/persistence/PersistenceProperty.class)]
6[INFO] ------------------------------------------------------------------------
7[INFO] Reactor Summary for My App 2.61.0-SNAPSHOT:
8[INFO] 
9[INFO] My App ............................. SUCCESS [  0.005 s]
10[INFO] My App - Webapp .................... FAILURE [  9.454 s]
11[INFO] ------------------------------------------------------------------------
12[INFO] BUILD FAILURE
13[INFO] ------------------------------------------------------------------------
14[INFO] Total time:  9.555 s
15[INFO] Finished at: 2021-09-21T10:31:24-03:00
16[INFO] ------------------------------------------------------------------------
17[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp-webapp: Compilation failure -> [Help 1]
18org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp-webapp: Compilation failure
19    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
20    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
21    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
22    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
23    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
24    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
25    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
26    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
27    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
28    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
29    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
30    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
31    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
32    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
33    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
34    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
35    at java.lang.reflect.Method.invoke (Method.java:568)
36    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
37    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
38    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
39    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
40Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
41    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1224)
42    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:187)
43    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
44    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
45    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
46    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
47    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
48    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
49    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
50    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
51    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
52    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
53    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
54    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
55    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
56    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
57    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
58    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
59    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
60    at java.lang.reflect.Method.invoke (Method.java:568)
61    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
62    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
63    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
64    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
65[ERROR] 
66[ERROR] 
67[ERROR] For more information about the errors and possible solutions, please read the following articles:
68[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
69[ERROR] 
70[ERROR] After correcting the problems, you can resume the build with the command
71[ERROR]   mvn <args> -rf :myapp-webapp
72

pom.xml (Parent)

1[INFO] [loading /Users/daniela/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar(/lombok/AllArgsConstructor$AnyAnnotation.class)]
2[INFO] [loading /Users/daniela/.m2/repository/org/ocpsoft/rewrite/rewrite-config-prettyfaces/2.0.4.Final/rewrite-config-prettyfaces-2.0.4.Final.jar(/com/ocpsoft/pretty/faces/annotation/URLValidator.class)]
3[INFO] [loading /Users/daniela/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar(/javax/servlet/annotation/WebInitParam.class)]
4[INFO] [loading /Users/daniela/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar(/lombok/RequiredArgsConstructor$AnyAnnotation.class)]
5[INFO] [loading /Users/daniela/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar(/javax/persistence/PersistenceProperty.class)]
6[INFO] ------------------------------------------------------------------------
7[INFO] Reactor Summary for My App 2.61.0-SNAPSHOT:
8[INFO] 
9[INFO] My App ............................. SUCCESS [  0.005 s]
10[INFO] My App - Webapp .................... FAILURE [  9.454 s]
11[INFO] ------------------------------------------------------------------------
12[INFO] BUILD FAILURE
13[INFO] ------------------------------------------------------------------------
14[INFO] Total time:  9.555 s
15[INFO] Finished at: 2021-09-21T10:31:24-03:00
16[INFO] ------------------------------------------------------------------------
17[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp-webapp: Compilation failure -> [Help 1]
18org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp-webapp: Compilation failure
19    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
20    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
21    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
22    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
23    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
24    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
25    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
26    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
27    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
28    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
29    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
30    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
31    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
32    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
33    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
34    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
35    at java.lang.reflect.Method.invoke (Method.java:568)
36    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
37    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
38    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
39    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
40Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
41    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1224)
42    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:187)
43    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
44    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
45    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
46    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
47    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
48    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
49    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
50    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
51    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
52    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
53    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
54    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
55    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
56    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
57    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
58    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
59    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
60    at java.lang.reflect.Method.invoke (Method.java:568)
61    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
62    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
63    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
64    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
65[ERROR] 
66[ERROR] 
67[ERROR] For more information about the errors and possible solutions, please read the following articles:
68[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
69[ERROR] 
70[ERROR] After correcting the problems, you can resume the build with the command
71[ERROR]   mvn <args> -rf :myapp-webapp
72<properties>
73
74        <!-- Generic properties -->
75        <java.version>17</java.version>
76        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
77        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
78
79        <!-- Java EE / Java SE dependencies -->
80        <jsp.version>2.2</jsp.version>
81        <jstl.version>1.2</jstl.version>
82        <servlet.version>3.1.0</servlet.version>
83        <javax-el.version>3.0.0</javax-el.version>
84        <jaxb-impl.version>2.2.7-b63</jaxb-impl.version>
85
86        <!-- Other dependencies such as Spring, Hibernate etc -->
87
88        <maven.compiler.source>17</maven.compiler.source>
89        <maven.compiler.target>17</maven.compiler.target>
90</properties>
91
92<build>
93
94        <pluginManagement>
95
96            <plugins>
97                <plugin>
98                    <groupId>org.apache.maven.plugins</groupId>
99                    <artifactId>maven-compiler-plugin</artifactId>
100                    <version>3.8.1</version>
101                    <configuration>
102                        <annotationProcessorPaths>
103                            <path>
104                                <groupId>org.projectlombok</groupId>
105                                <artifactId>lombok</artifactId>
106                                <version>${lombok.version}</version>
107                            </path>
108                        </annotationProcessorPaths>
109                        <compilerArguments>
110                            <verbose />
111                            <Xlint />
112                        </compilerArguments>
113                        <fork>true</fork>
114                        <verbose>true</verbose>
115                        <source>17</source>
116                        <target>17</target>
117                        <showWarnings>true</showWarnings>
118                        <compilerVersion>17</compilerVersion>
119                        <debug>true</debug>
120                    </configuration>
121                </plugin>
122
123                <plugin>
124                    <groupId>org.apache.maven.plugins</groupId>
125                    <artifactId>maven-war-plugin</artifactId>
126                    <version>2.4</version>
127                    <configuration>
128                        <warName>${project.build.finalName}</warName>
129                    </configuration>
130                </plugin>
131
132                <plugin>
133                    <groupId>org.apache.maven.plugins</groupId>
134                    <artifactId>maven-release-plugin</artifactId>
135                    <version>2.5</version>
136                    <dependencies>
137                        <dependency>
138                            <groupId>org.apache.maven.scm</groupId>
139                            <artifactId>maven-scm-provider-gitexe</artifactId>
140                            <version>1.9.2</version>
141                        </dependency>
142                    </dependencies>
143                    <configuration>
144                        <arguments>-Dbuild-env=${build-env}</arguments>
145                    </configuration>
146                </plugin>
147
148                <plugin>
149                    <groupId>org.apache.maven.plugins</groupId>
150                    <artifactId>maven-javadoc-plugin</artifactId>
151                    <version>2.9</version>
152                    <configuration>
153                        <skip>true</skip>
154                    </configuration>
155                </plugin>
156
157                <plugin>
158                    <artifactId>maven-clean-plugin</artifactId>
159                    <version>2.6.1</version>
160                </plugin>
161
162                <plugin>
163                    <artifactId>maven-resources-plugin</artifactId>
164                    <version>2.7</version>
165                    <executions>
166                        <execution>
167                            <id>copy-resources</id>
168                            <phase>validate</phase>
169                            <goals>
170                                <goal>copy-resources</goal>
171                            </goals>
172                            <configuration>
173                                <outputDirectory>${project.build.outputDirectory}/com/my/app/bundle</outputDirectory>
174                                <resources>
175                                    <resource>
176                                        <directory>src/main/resources/my/app/bundle</directory>
177                                        <filtering>true</filtering>
178                                    </resource>
179                                </resources>
180                            </configuration>
181                        </execution>
182                    </executions>
183                </plugin>
184
185                <plugin>
186                        <groupId>org.apache.maven.plugins</groupId>
187                        <artifactId>maven-site-plugin</artifactId>
188                        <version>3.9.1</version>
189                </plugin>
190
191                <plugin>
192                    <groupId>org.apache.maven.plugins</groupId>
193                    <artifactId>maven-project-info-reports-plugin</artifactId>
194                    <version>3.1.2</version>
195                </plugin>
196            </plugins>
197
198        </pluginManagement>
199        <plugins>
200            <plugin>
201                <groupId>org.apache.maven.plugins</groupId>
202                <artifactId>maven-compiler-plugin</artifactId>
203            </plugin>
204
205        </plugins>
206
207    </build>
208

pom.xml (Child)

1[INFO] [loading /Users/daniela/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar(/lombok/AllArgsConstructor$AnyAnnotation.class)]
2[INFO] [loading /Users/daniela/.m2/repository/org/ocpsoft/rewrite/rewrite-config-prettyfaces/2.0.4.Final/rewrite-config-prettyfaces-2.0.4.Final.jar(/com/ocpsoft/pretty/faces/annotation/URLValidator.class)]
3[INFO] [loading /Users/daniela/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar(/javax/servlet/annotation/WebInitParam.class)]
4[INFO] [loading /Users/daniela/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar(/lombok/RequiredArgsConstructor$AnyAnnotation.class)]
5[INFO] [loading /Users/daniela/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar(/javax/persistence/PersistenceProperty.class)]
6[INFO] ------------------------------------------------------------------------
7[INFO] Reactor Summary for My App 2.61.0-SNAPSHOT:
8[INFO] 
9[INFO] My App ............................. SUCCESS [  0.005 s]
10[INFO] My App - Webapp .................... FAILURE [  9.454 s]
11[INFO] ------------------------------------------------------------------------
12[INFO] BUILD FAILURE
13[INFO] ------------------------------------------------------------------------
14[INFO] Total time:  9.555 s
15[INFO] Finished at: 2021-09-21T10:31:24-03:00
16[INFO] ------------------------------------------------------------------------
17[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp-webapp: Compilation failure -> [Help 1]
18org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp-webapp: Compilation failure
19    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
20    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
21    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
22    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
23    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
24    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
25    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
26    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
27    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
28    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
29    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
30    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
31    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
32    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
33    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
34    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
35    at java.lang.reflect.Method.invoke (Method.java:568)
36    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
37    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
38    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
39    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
40Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
41    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1224)
42    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:187)
43    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
44    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
45    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
46    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
47    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
48    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
49    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
50    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
51    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
52    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
53    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
54    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
55    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
56    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
57    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
58    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
59    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
60    at java.lang.reflect.Method.invoke (Method.java:568)
61    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
62    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
63    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
64    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
65[ERROR] 
66[ERROR] 
67[ERROR] For more information about the errors and possible solutions, please read the following articles:
68[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
69[ERROR] 
70[ERROR] After correcting the problems, you can resume the build with the command
71[ERROR]   mvn <args> -rf :myapp-webapp
72<properties>
73
74        <!-- Generic properties -->
75        <java.version>17</java.version>
76        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
77        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
78
79        <!-- Java EE / Java SE dependencies -->
80        <jsp.version>2.2</jsp.version>
81        <jstl.version>1.2</jstl.version>
82        <servlet.version>3.1.0</servlet.version>
83        <javax-el.version>3.0.0</javax-el.version>
84        <jaxb-impl.version>2.2.7-b63</jaxb-impl.version>
85
86        <!-- Other dependencies such as Spring, Hibernate etc -->
87
88        <maven.compiler.source>17</maven.compiler.source>
89        <maven.compiler.target>17</maven.compiler.target>
90</properties>
91
92<build>
93
94        <pluginManagement>
95
96            <plugins>
97                <plugin>
98                    <groupId>org.apache.maven.plugins</groupId>
99                    <artifactId>maven-compiler-plugin</artifactId>
100                    <version>3.8.1</version>
101                    <configuration>
102                        <annotationProcessorPaths>
103                            <path>
104                                <groupId>org.projectlombok</groupId>
105                                <artifactId>lombok</artifactId>
106                                <version>${lombok.version}</version>
107                            </path>
108                        </annotationProcessorPaths>
109                        <compilerArguments>
110                            <verbose />
111                            <Xlint />
112                        </compilerArguments>
113                        <fork>true</fork>
114                        <verbose>true</verbose>
115                        <source>17</source>
116                        <target>17</target>
117                        <showWarnings>true</showWarnings>
118                        <compilerVersion>17</compilerVersion>
119                        <debug>true</debug>
120                    </configuration>
121                </plugin>
122
123                <plugin>
124                    <groupId>org.apache.maven.plugins</groupId>
125                    <artifactId>maven-war-plugin</artifactId>
126                    <version>2.4</version>
127                    <configuration>
128                        <warName>${project.build.finalName}</warName>
129                    </configuration>
130                </plugin>
131
132                <plugin>
133                    <groupId>org.apache.maven.plugins</groupId>
134                    <artifactId>maven-release-plugin</artifactId>
135                    <version>2.5</version>
136                    <dependencies>
137                        <dependency>
138                            <groupId>org.apache.maven.scm</groupId>
139                            <artifactId>maven-scm-provider-gitexe</artifactId>
140                            <version>1.9.2</version>
141                        </dependency>
142                    </dependencies>
143                    <configuration>
144                        <arguments>-Dbuild-env=${build-env}</arguments>
145                    </configuration>
146                </plugin>
147
148                <plugin>
149                    <groupId>org.apache.maven.plugins</groupId>
150                    <artifactId>maven-javadoc-plugin</artifactId>
151                    <version>2.9</version>
152                    <configuration>
153                        <skip>true</skip>
154                    </configuration>
155                </plugin>
156
157                <plugin>
158                    <artifactId>maven-clean-plugin</artifactId>
159                    <version>2.6.1</version>
160                </plugin>
161
162                <plugin>
163                    <artifactId>maven-resources-plugin</artifactId>
164                    <version>2.7</version>
165                    <executions>
166                        <execution>
167                            <id>copy-resources</id>
168                            <phase>validate</phase>
169                            <goals>
170                                <goal>copy-resources</goal>
171                            </goals>
172                            <configuration>
173                                <outputDirectory>${project.build.outputDirectory}/com/my/app/bundle</outputDirectory>
174                                <resources>
175                                    <resource>
176                                        <directory>src/main/resources/my/app/bundle</directory>
177                                        <filtering>true</filtering>
178                                    </resource>
179                                </resources>
180                            </configuration>
181                        </execution>
182                    </executions>
183                </plugin>
184
185                <plugin>
186                        <groupId>org.apache.maven.plugins</groupId>
187                        <artifactId>maven-site-plugin</artifactId>
188                        <version>3.9.1</version>
189                </plugin>
190
191                <plugin>
192                    <groupId>org.apache.maven.plugins</groupId>
193                    <artifactId>maven-project-info-reports-plugin</artifactId>
194                    <version>3.1.2</version>
195                </plugin>
196            </plugins>
197
198        </pluginManagement>
199        <plugins>
200            <plugin>
201                <groupId>org.apache.maven.plugins</groupId>
202                <artifactId>maven-compiler-plugin</artifactId>
203            </plugin>
204
205        </plugins>
206
207    </build>
208<properties>
209        <java.version>17</java.version>
210
211        <maven.compiler.source>17</maven.compiler.source>
212        <maven.compiler.target>17</maven.compiler.target>
213</properties>
214
215<profiles>
216        <profile>
217            <id>dev</id>
218            <activation>
219                <activeByDefault>true</activeByDefault>
220            </activation>
221
222            <build>
223                <finalName>myapp</finalName>
224                <plugins>
225
226                    <plugin>
227                        <groupId>org.apache.maven.plugins</groupId>
228                        <artifactId>maven-war-plugin</artifactId>
229                    </plugin>
230
231                    <plugin>
232                        <groupId>org.apache.maven.plugins</groupId>
233                        <artifactId>maven-surefire-plugin</artifactId>
234                        <configuration>
235                            <includes>
236                                <include>**/*IT.java</include>
237                            </includes>
238                        </configuration>
239                        <version>2.18.1</version>
240                    </plugin>
241
242                    <plugin>
243                        <groupId>org.apache.maven.plugins</groupId>
244                        <artifactId>maven-compiler-plugin</artifactId>
245                        <inherited>true</inherited>
246                    </plugin>
247
248                    <plugin>
249                        <groupId>org.apache.maven.plugins</groupId>
250                        <artifactId>maven-dependency-plugin</artifactId>
251                    </plugin>
252                    <plugin>
253                        <artifactId>maven-release-plugin</artifactId>
254                    </plugin>
255                    <plugin>
256                        <groupId>org.apache.maven.plugins</groupId>
257                        <artifactId>maven-site-plugin</artifactId>
258                    </plugin>
259                    <plugin>
260                        <groupId>org.apache.maven.plugins</groupId>
261                        <artifactId>maven-project-info-reports-plugin</artifactId>
262                    </plugin>
263                </plugins>
264            </build>
265        </profile>
266</profile>      
267

Java and mvn version

1[INFO] [loading /Users/daniela/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar(/lombok/AllArgsConstructor$AnyAnnotation.class)]
2[INFO] [loading /Users/daniela/.m2/repository/org/ocpsoft/rewrite/rewrite-config-prettyfaces/2.0.4.Final/rewrite-config-prettyfaces-2.0.4.Final.jar(/com/ocpsoft/pretty/faces/annotation/URLValidator.class)]
3[INFO] [loading /Users/daniela/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar(/javax/servlet/annotation/WebInitParam.class)]
4[INFO] [loading /Users/daniela/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar(/lombok/RequiredArgsConstructor$AnyAnnotation.class)]
5[INFO] [loading /Users/daniela/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar(/javax/persistence/PersistenceProperty.class)]
6[INFO] ------------------------------------------------------------------------
7[INFO] Reactor Summary for My App 2.61.0-SNAPSHOT:
8[INFO] 
9[INFO] My App ............................. SUCCESS [  0.005 s]
10[INFO] My App - Webapp .................... FAILURE [  9.454 s]
11[INFO] ------------------------------------------------------------------------
12[INFO] BUILD FAILURE
13[INFO] ------------------------------------------------------------------------
14[INFO] Total time:  9.555 s
15[INFO] Finished at: 2021-09-21T10:31:24-03:00
16[INFO] ------------------------------------------------------------------------
17[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp-webapp: Compilation failure -> [Help 1]
18org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp-webapp: Compilation failure
19    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
20    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
21    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
22    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
23    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
24    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
25    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
26    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
27    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
28    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
29    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
30    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
31    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
32    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
33    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
34    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
35    at java.lang.reflect.Method.invoke (Method.java:568)
36    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
37    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
38    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
39    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
40Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
41    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1224)
42    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:187)
43    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
44    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
45    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
46    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
47    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
48    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
49    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
50    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
51    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
52    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
53    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
54    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
55    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
56    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
57    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
58    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
59    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
60    at java.lang.reflect.Method.invoke (Method.java:568)
61    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
62    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
63    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
64    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
65[ERROR] 
66[ERROR] 
67[ERROR] For more information about the errors and possible solutions, please read the following articles:
68[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
69[ERROR] 
70[ERROR] After correcting the problems, you can resume the build with the command
71[ERROR]   mvn <args> -rf :myapp-webapp
72<properties>
73
74        <!-- Generic properties -->
75        <java.version>17</java.version>
76        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
77        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
78
79        <!-- Java EE / Java SE dependencies -->
80        <jsp.version>2.2</jsp.version>
81        <jstl.version>1.2</jstl.version>
82        <servlet.version>3.1.0</servlet.version>
83        <javax-el.version>3.0.0</javax-el.version>
84        <jaxb-impl.version>2.2.7-b63</jaxb-impl.version>
85
86        <!-- Other dependencies such as Spring, Hibernate etc -->
87
88        <maven.compiler.source>17</maven.compiler.source>
89        <maven.compiler.target>17</maven.compiler.target>
90</properties>
91
92<build>
93
94        <pluginManagement>
95
96            <plugins>
97                <plugin>
98                    <groupId>org.apache.maven.plugins</groupId>
99                    <artifactId>maven-compiler-plugin</artifactId>
100                    <version>3.8.1</version>
101                    <configuration>
102                        <annotationProcessorPaths>
103                            <path>
104                                <groupId>org.projectlombok</groupId>
105                                <artifactId>lombok</artifactId>
106                                <version>${lombok.version}</version>
107                            </path>
108                        </annotationProcessorPaths>
109                        <compilerArguments>
110                            <verbose />
111                            <Xlint />
112                        </compilerArguments>
113                        <fork>true</fork>
114                        <verbose>true</verbose>
115                        <source>17</source>
116                        <target>17</target>
117                        <showWarnings>true</showWarnings>
118                        <compilerVersion>17</compilerVersion>
119                        <debug>true</debug>
120                    </configuration>
121                </plugin>
122
123                <plugin>
124                    <groupId>org.apache.maven.plugins</groupId>
125                    <artifactId>maven-war-plugin</artifactId>
126                    <version>2.4</version>
127                    <configuration>
128                        <warName>${project.build.finalName}</warName>
129                    </configuration>
130                </plugin>
131
132                <plugin>
133                    <groupId>org.apache.maven.plugins</groupId>
134                    <artifactId>maven-release-plugin</artifactId>
135                    <version>2.5</version>
136                    <dependencies>
137                        <dependency>
138                            <groupId>org.apache.maven.scm</groupId>
139                            <artifactId>maven-scm-provider-gitexe</artifactId>
140                            <version>1.9.2</version>
141                        </dependency>
142                    </dependencies>
143                    <configuration>
144                        <arguments>-Dbuild-env=${build-env}</arguments>
145                    </configuration>
146                </plugin>
147
148                <plugin>
149                    <groupId>org.apache.maven.plugins</groupId>
150                    <artifactId>maven-javadoc-plugin</artifactId>
151                    <version>2.9</version>
152                    <configuration>
153                        <skip>true</skip>
154                    </configuration>
155                </plugin>
156
157                <plugin>
158                    <artifactId>maven-clean-plugin</artifactId>
159                    <version>2.6.1</version>
160                </plugin>
161
162                <plugin>
163                    <artifactId>maven-resources-plugin</artifactId>
164                    <version>2.7</version>
165                    <executions>
166                        <execution>
167                            <id>copy-resources</id>
168                            <phase>validate</phase>
169                            <goals>
170                                <goal>copy-resources</goal>
171                            </goals>
172                            <configuration>
173                                <outputDirectory>${project.build.outputDirectory}/com/my/app/bundle</outputDirectory>
174                                <resources>
175                                    <resource>
176                                        <directory>src/main/resources/my/app/bundle</directory>
177                                        <filtering>true</filtering>
178                                    </resource>
179                                </resources>
180                            </configuration>
181                        </execution>
182                    </executions>
183                </plugin>
184
185                <plugin>
186                        <groupId>org.apache.maven.plugins</groupId>
187                        <artifactId>maven-site-plugin</artifactId>
188                        <version>3.9.1</version>
189                </plugin>
190
191                <plugin>
192                    <groupId>org.apache.maven.plugins</groupId>
193                    <artifactId>maven-project-info-reports-plugin</artifactId>
194                    <version>3.1.2</version>
195                </plugin>
196            </plugins>
197
198        </pluginManagement>
199        <plugins>
200            <plugin>
201                <groupId>org.apache.maven.plugins</groupId>
202                <artifactId>maven-compiler-plugin</artifactId>
203            </plugin>
204
205        </plugins>
206
207    </build>
208<properties>
209        <java.version>17</java.version>
210
211        <maven.compiler.source>17</maven.compiler.source>
212        <maven.compiler.target>17</maven.compiler.target>
213</properties>
214
215<profiles>
216        <profile>
217            <id>dev</id>
218            <activation>
219                <activeByDefault>true</activeByDefault>
220            </activation>
221
222            <build>
223                <finalName>myapp</finalName>
224                <plugins>
225
226                    <plugin>
227                        <groupId>org.apache.maven.plugins</groupId>
228                        <artifactId>maven-war-plugin</artifactId>
229                    </plugin>
230
231                    <plugin>
232                        <groupId>org.apache.maven.plugins</groupId>
233                        <artifactId>maven-surefire-plugin</artifactId>
234                        <configuration>
235                            <includes>
236                                <include>**/*IT.java</include>
237                            </includes>
238                        </configuration>
239                        <version>2.18.1</version>
240                    </plugin>
241
242                    <plugin>
243                        <groupId>org.apache.maven.plugins</groupId>
244                        <artifactId>maven-compiler-plugin</artifactId>
245                        <inherited>true</inherited>
246                    </plugin>
247
248                    <plugin>
249                        <groupId>org.apache.maven.plugins</groupId>
250                        <artifactId>maven-dependency-plugin</artifactId>
251                    </plugin>
252                    <plugin>
253                        <artifactId>maven-release-plugin</artifactId>
254                    </plugin>
255                    <plugin>
256                        <groupId>org.apache.maven.plugins</groupId>
257                        <artifactId>maven-site-plugin</artifactId>
258                    </plugin>
259                    <plugin>
260                        <groupId>org.apache.maven.plugins</groupId>
261                        <artifactId>maven-project-info-reports-plugin</artifactId>
262                    </plugin>
263                </plugins>
264            </build>
265        </profile>
266</profile>      
267daniela@Danielas-Macbook ~> javac -version
268javac 17
269daniela@Danielas-Macbook ~> mvn --version
270Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
271Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
272Java version: 17
273

I changed the java version in maven to execute with JDK 8 and JDK 11 and there's no error: BUILD SUCCESS. I got the error in JDK 16 and 17.

ANSWER

Answered 2021-Oct-19 at 20:28

This failure is likely due to an issue between java 17 and older lombok versions. Building with java 17.0.1, lombok 1.18.20 and maven 3.8.1 caused a vague "Compilation failure" for me as well. I upgraded to maven 3.8.3 which also failed but provided this detail on the failure:

java.lang.NullPointerException: Cannot read field "bindingsWhenTrue" because "currentBindings" is null

Searching for this failure message I found this issue on stackoverflow leading me to a bug in lombok. I upgraded to lombok 1.18.22 and that fixed the compilation failure for a successful build.

Source https://stackoverflow.com/questions/69272445

QUESTION

@EnableAutoConfiguration(exclude =...) on tests failed in Spring Boot 2.6.0

Asked 2022-Jan-15 at 03:04

I tried to upgrade my data-mongo example project to Spring Boot 2.6.0. There is a test designed to run against Testcontainers, I also included the embedded mongo dep for other tests, so I have to exclude the AutoConfiguration for embedded mongo to make sure this test working on Docker/testcontainers.

The following configuration worked well with Spring Boot 2.5.6.

1
2@DataMongoTest
3@ContextConfiguration(initializers = {MongodbContainerInitializer.class})
4@EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
5@Slf4j
6@ActiveProfiles("test")
7public class PostRepositoryTest {}
8

But after upgrading to Spring Boot 2.6.0 and running the application, I got the exception like this.

1
2@DataMongoTest
3@ContextConfiguration(initializers = {MongodbContainerInitializer.class})
4@EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)
5@Slf4j
6@ActiveProfiles("test")
7public class PostRepositoryTest {}
8[           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: o
9rg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'embeddedMongoServer' defined in class path resource [org/springframework/boot/autoconfig
10ure/mongo/embedded/EmbeddedMongoAutoConfiguration.class]: Unsatisfied dependency expressed through method 'embeddedMongoServer' parameter 0; nested exception is org.springframework.bea
11ns.factory.BeanCreationException: Error creating bean with name 'embeddedMongoConfiguration' defined in class path resource [org/springframework/boot/autoconfigure/mongo/embedded/Embed
12dedMongoAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.flap
13doodle.embed.mongo.config.MongodConfig]: Factory method 'embeddedMongoConfiguration' threw exception; nested exception is java.lang.IllegalStateException: Set the spring.mongodb.embedd
14ed.version property or define your own MongodConfig bean to use embedded MongoDB
15

Obviously, @EnableAutoConfiguration(exclude =...) did not affect the context in tests when upgrading to Spring Boot 2.6.0.

Update: Temporarily resolved it, see my answer below.

ANSWER

Answered 2021-Nov-20 at 17:20

As of Spring Boot 2.6, the property spring.mongodb.embedded.version must be set to use the auto-configured embedded MongoDB. It's mentioned in the release notes: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.6-Release-Notes#embedded-mongo

This is also what the error message you posted, advises to do: Set the spring.mongodb.embedd ed.version property or define your own MongodConfig bean to use embedded MongoDB

The annotation @DataMongoTest is meta-annotated with @ImportAutoConfiguration and @AutoConfigureDataMongo, and is designed to trigger auto-configuration of MongoDB unless explicitly disabled as you do in the working configuration examples.

In your first configuration example, the annotation @EnableAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class) does not override this effect of @DataMongoTest.

With Spring Boot 2.5.6, the auto-configured MongodConfig bean is most likely also part of the application context but not effectively used. But this depends on the rest of the code and in particular on the MongodbContainerInitializer.

Source https://stackoverflow.com/questions/70047380

QUESTION

How to edit configmap configuration in spring boot kubernetes application during runtime

Asked 2021-Dec-16 at 06:50

We have application with huge configuration (this is just a part):

1apiVersion: v1
2kind: ConfigMap
3metadata:
4  name: my-app
5data:
6  application.yaml: |-
7    config:
8      app: MY-APP
9      my-custom-map:
10        KEY1: value1
11        KEY2: value2
12        KEY3: value3
13        KEY4: value4
14      something1: true
15      something2: 123
16      something3: string123
17      something4: null
18      subclass:
19        anotherMap:
20          "[AAA:0.0.1,BBB:CCC]": "DDD:EEEE"
21      subclass2:
22        something4: AAAA
23        anotherMap2:
24          0.0.3: 0.0.3
25

I follow this example to bind configmap with spring boot configuration but there is still some problem for example how to solve null in yaml which spring yaml postprocessor resolve as empty string: issue

second problem is how to handle this configmap. I know I can edit and then use apply but this can lead to some error. Is there some tool which I can use to edit this yaml and make some bash script for editing ? like: ./my-script.sh -function addMyCustomMapValue -args "KEY5:value5" . I tried to explore yq but I think there is some limitation and it is hard to use for some use-case and then kustomize which I think is good for creating configmap but not for editing existing one.

Is there already some good example for this use-case ?

ANSWER

Answered 2021-Dec-16 at 06:50

Option : 1

You can Use the Lens : https://k8slens.dev/kubernetes.html

It's UI for monitoring and Managing K8s clusters. Using this you can also edit the configmap.

Option : 2

You can manage all the Key value into single YAML file and create configmap from file :

1apiVersion: v1
2kind: ConfigMap
3metadata:
4  name: my-app
5data:
6  application.yaml: |-
7    config:
8      app: MY-APP
9      my-custom-map:
10        KEY1: value1
11        KEY2: value2
12        KEY3: value3
13        KEY4: value4
14      something1: true
15      something2: 123
16      something3: string123
17      something4: null
18      subclass:
19        anotherMap:
20          "[AAA:0.0.1,BBB:CCC]": "DDD:EEEE"
21      subclass2:
22        something4: AAAA
23        anotherMap2:
24          0.0.3: 0.0.3
25kubectl create configmap some-config \
26  --from-file=some-key=some-config.yaml \
27  -n some-namespace \
28  -o yaml \
29  --dry-run | kubectl apply -f - 
30

Option : 3

Use helm and values.yaml template to create and your chart and apply it further.

Configmap using YAML helm

1apiVersion: v1
2kind: ConfigMap
3metadata:
4  name: my-app
5data:
6  application.yaml: |-
7    config:
8      app: MY-APP
9      my-custom-map:
10        KEY1: value1
11        KEY2: value2
12        KEY3: value3
13        KEY4: value4
14      something1: true
15      something2: 123
16      something3: string123
17      something4: null
18      subclass:
19        anotherMap:
20          "[AAA:0.0.1,BBB:CCC]": "DDD:EEEE"
21      subclass2:
22        something4: AAAA
23        anotherMap2:
24          0.0.3: 0.0.3
25kubectl create configmap some-config \
26  --from-file=some-key=some-config.yaml \
27  -n some-namespace \
28  -o yaml \
29  --dry-run | kubectl apply -f - 
30apiVersion: v1
31kind: ConfigMap
32metadata:
33  name: jksconfig
34data:
35  config.json: |-
36    {{ .Files.Get "config.json" | indent 4 }}
37

Option : 4

If you are using the configmap as Environment or injecting it to file path you can use the Hashi corp vault also : https://www.vaultproject.io/

Option : 5

As you suggested you can create one Bash script which will export the existing running Configmap to a new YAML file one you are done with editing YAML manually. You can apply the changes to K8s cluster.

1apiVersion: v1
2kind: ConfigMap
3metadata:
4  name: my-app
5data:
6  application.yaml: |-
7    config:
8      app: MY-APP
9      my-custom-map:
10        KEY1: value1
11        KEY2: value2
12        KEY3: value3
13        KEY4: value4
14      something1: true
15      something2: 123
16      something3: string123
17      something4: null
18      subclass:
19        anotherMap:
20          "[AAA:0.0.1,BBB:CCC]": "DDD:EEEE"
21      subclass2:
22        something4: AAAA
23        anotherMap2:
24          0.0.3: 0.0.3
25kubectl create configmap some-config \
26  --from-file=some-key=some-config.yaml \
27  -n some-namespace \
28  -o yaml \
29  --dry-run | kubectl apply -f - 
30apiVersion: v1
31kind: ConfigMap
32metadata:
33  name: jksconfig
34data:
35  config.json: |-
36    {{ .Files.Get "config.json" | indent 4 }}
37#bin/bash
38kubectl get configmap <configmap-name>  -o yaml > cofig.yaml
39

You can also check the : https://github.com/Gallore/yaml_cli might be helpful.

Source https://stackoverflow.com/questions/70261702

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Spring

Tutorials and Learning Resources are not available at this moment for Spring

Share this Page

share link

Get latest updates on Spring