springboot 2.6.0 :
2021-11-24 10:45:15,633 INFO [restartedMain] o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter [LogAccessor.java : 292] started bean 'inbound'; defined in: 'class path resource [com/yaken/config/MqttConfig.class]'; from source: 'com.yaken.config.MqttConfig.inbound()'
2021-11-24 10:45:15,639 INFO [restartedMain] io.undertow [Undertow.java : 120] starting server: Undertow - 2.2.12.Final
2021-11-24 10:45:15,646 INFO [restartedMain] org.xnio [Xnio.java : 95] XNIO version 3.8.4.Final
2021-11-24 10:45:15,655 INFO [restartedMain] org.xnio.nio [NioXnio.java : 58] XNIO NIO Implementation Version 3.8.4.Final
2021-11-24 10:45:15,724 INFO [restartedMain] org.jboss.threads [Version.java : 52] JBoss Threads version 3.1.0.Final
2021-11-24 10:45:15,767 INFO [restartedMain] o.s.b.w.e.undertow.UndertowWebServer [UndertowWebServer.java : 119] Undertow started on port(s) 8888 (http)
2021-11-24 10:45:15,772 WARN [restartedMain] o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext [AbstractApplicationContext.java : 591] 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
2021-11-24 10:45:15,772 INFO [restartedMain] o.s.i.endpoint.EventDrivenConsumer [LogAccessor.java : 174] Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2021-11-24 10:45:15,773 INFO [restartedMain] o.s.i.c.PublishSubscribeChannel [LogAccessor.java : 174] Channel 'yaken.errorChannel' has 0 subscriber(s).
2021-11-24 10:45:15,773 INFO [restartedMain] o.s.i.endpoint.EventDrivenConsumer [LogAccessor.java : 292] stopped bean '_org.springframework.integration.errorLogger'
2021-11-24 10:45:19,784 ERROR [MQTT Ping: 1133363739727241217_inbound] o.e.p.c.mqttv3.internal.ClientState [JSR47Logger.java : 210] 1133363739727241217_inbound: Timed out as no activity, keepAlive=2,000,000,000 lastOutboundActivity=86,592,399,738,807 lastInboundActivity=86,590,398,064,634 time=86,594,402,071,285 lastPing=86,592,399,744,206
2021-11-24 10:45:19,786 INFO [restartedMain] o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter [LogAccessor.java : 292] stopped bean 'inbound'; defined in: 'class path resource [com/yaken/config/MqttConfig.class]'; from source: 'com.yaken.config.MqttConfig.inbound()'
2021-11-24 10:45:19,793 INFO [restartedMain] o.s.i.g.GatewayProxyFactoryBean$MethodInvocationGateway [LogAccessor.java : 292] stopped bean 'mqttGateway#sendToMqtt(String, String)'
2021-11-24 10:45:19,793 INFO [restartedMain] o.s.i.g.GatewayProxyFactoryBean [LogAccessor.java : 292] stopped bean 'mqttGateway'
2021-11-24 10:45:19,802 INFO [restartedMain] io.undertow [Undertow.java : 259] stopping server: Undertow - 2.2.12.Final
2021-11-24 10:45:19,824 INFO [restartedMain] o.s.b.a.l.ConditionEvaluationReportLoggingListener [ConditionEvaluationReportLoggingListener.java : 136]
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-11-24 10:45:19,845 ERROR [restartedMain] o.s.boot.SpringApplication [SpringApplication.java : 819] Application run failed
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
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
at com.yaken.YakenApplication.main(YakenApplication.java:24)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56)
at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113)
at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89)
at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:473)
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.base/java.util.TimSort.sort(TimSort.java:234)
at java.base/java.util.Arrays.sort(Arrays.java:1307)
at java.base/java.util.ArrayList.sort(ArrayList.java:1721)
at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:392)
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider.requestHandlers(WebMvcRequestHandlerProvider.java:81)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.withDefaults(AbstractDocumentationPluginsBootstrapper.java:107)
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.buildContext(AbstractDocumentationPluginsBootstrapper.java:91)
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82)
at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
... 19 common frames omitted
Comment From: weir2010
springboot 2.5.7 is ok
Comment From: snicoll
This is a springfox problem that should be reported against the relevant project. See also https://github.com/spring-projects/spring-boot/issues/28769
Comment From: wilkinsona
https://github.com/springfox/springfox/issues/3462 is already tracking this on the Springfox side.
Comment From: weir2010
be careful:
2021-11-24 10:45:19,784 ERROR [MQTT Ping: 1133363739727241217_inbound] o.e.p.c.mqttv3.internal.ClientState [JSR47Logger.java : 210] 1133363739727241217_inbound: Timed out as no activity, keepAlive=2,000,000,000 lastOutboundActivity=86,592,399,738,807 lastInboundActivity=86,590,398,064,634 time=86,594,402,071,285 lastPing=86,592,399,744,206
Not because springfox ,I have a problem using mqtt
Comment From: wilkinsona
@weir2010 Can you please provide some more context for your comment? I don't see the connection between MQTT and web request path parsing.
Comment From: weir2010
critical code:
package com.yaken.config;
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
import com.yaken.mqtt.MqttReceiveService;
import lombok.extern.slf4j.Slf4j;
/**
* MQTT接收消息处理
*
* @author weir
*
* 2019年6月16日 下午2:41:45
*/
@Slf4j
@Configuration
@IntegrationComponentScan
public class MqttConfig {
private static final String MQTT_RECEIVEDTOPIC = "mqtt_receivedTopic";
private static final String SP_INBOUND = "_inbound";
private MqttPahoMessageDrivenChannelAdapter adapter;
@Value("${mqtt.username}")
private String username;
@Value("${mqtt.pwd}")
private String password;
@Value("${mqtt.url}")
private String hostUrl;
@Value("${mqtt.client.id}")
private String clientId;
@Value("${mqtt.default.topic}")
private String defaultTopic;
@Value("${mqtt.completionTimeout}")
private int completionTimeout;
@Autowired
private MqttReceiveService mqttReceiveService;
@Bean
public MqttConnectOptions getMqttConnectOptions() {
MqttConnectOptions mqttConnectOptions = new MqttConnectOptions();
mqttConnectOptions.setUserName(username);
mqttConnectOptions.setPassword(password.toCharArray());
mqttConnectOptions.setServerURIs(new String[] { hostUrl });
mqttConnectOptions.setKeepAliveInterval(2); // 设置会话心跳时间
return mqttConnectOptions;
}
@Bean
public MqttPahoClientFactory mqttClientFactory() {
DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
factory.setConnectionOptions(getMqttConnectOptions());
return factory;
}
@Bean
@ServiceActivator(inputChannel = "mqttOutboundChannel")
public MessageHandler mqttOutbound() {
MqttPahoMessageHandler messageHandler = new MqttPahoMessageHandler(clientId, mqttClientFactory());
messageHandler.setAsync(true);
messageHandler.setDefaultTopic(defaultTopic);
return messageHandler;
}
@Bean
public MessageChannel mqttOutboundChannel() {
return new DirectChannel();
}
/**
* 接收通道
*
* @return MessageChannel
*/
@Bean
public MessageChannel mqttInputChannel() {
return new DirectChannel();
}
/**
* 配置client,监听的topic
*
* @return MessageProducer
*/
@Bean
public MessageProducer inbound() {
adapter = new MqttPahoMessageDrivenChannelAdapter(clientId + SP_INBOUND, mqttClientFactory(), defaultTopic);
adapter.setCompletionTimeout(completionTimeout);
adapter.setConverter(new DefaultPahoMessageConverter());
adapter.setOutputChannel(mqttInputChannel());
return adapter;
}
}
Comment From: philwebb
@weir2010 It's still not clear how the sample code you've provided in the comment above relates to the stacktrace that you initially posted. If you believe that this is a Spring Boot issue please provide a sample application that (as a zip file for github project) that reproduces the issue and doesn't have springfox as a dependency.
Comment From: weir2010
I found the problem. It's really swagger ok
Comment From: JuKu
I have the same problem with the newest Spring version 2.6.1 and springfox-swagger2 version 3.0.0 . Is there a workaround?
Comment From: notforward
same problem as mentioned above
Comment From: rcbandit111
Any update? Any plans to release a fixed version?
Comment From: snicoll
Please read the issue history before commenting. This is a springfox issue and nothing we can do here.
Comment From: segomin
https://github.com/springfox/springfox/issues/3462#issuecomment-978707909 helped me btw.
Comment From: mert-unsal
To work around this problem, you can add @EnableWebMvc to spring-context. You are gonna need to disable on testing, @Profile(!test) @EnableWebMvc
This will let you work around the problem.
Comment From: wilkinsona
Thanks for trying to help, @mert-unsal. Unfortunately, that's almost certainly going to have additional unwanted effects as it will disable all of Spring Boot's auto-configuration of Spring MVC.
Comment From: amitbd1508
` package com.miniprojecttwo.productservice.config;
import org.springframework.beans.factory.InitializingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.*; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.RequestHandlerProvider; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.WebMvcRequestHandler; import springfox.documentation.spring.web.paths.Paths; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper; import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; import springfox.documentation.spring.web.readers.operation.HandlerMethodResolver;
import javax.servlet.ServletContext; import java.util.*; import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList; import static springfox.documentation.RequestHandler.byPatternsCondition;
@Configuration public class SwaggerConfiguration {
public static final String AUTHORIZATION_HEADER = "Authorization";
private ApiInfo apiInfo() { return new ApiInfo("My REST API", "Some custom description of API.", "1.0", "Terms of service", new Contact("Sallo Szrajbman", "www.baeldung.com", "salloszraj@gmail.com"), "License of API", "API license URL", Collections.emptyList()); }
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .securityContexts(Arrays.asList(securityContext())) .securitySchemes(Arrays.asList(apiKey())) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build(); }
private ApiKey apiKey() { return new ApiKey("Bearer", AUTHORIZATION_HEADER, "header"); }
private SecurityContext securityContext() { return SecurityContext.builder() .securityReferences(defaultAuth()) .build(); }
List
@Bean public InitializingBean removeSpringfoxHandlerProvider(DocumentationPluginsBootstrapper bootstrapper) { return () -> bootstrapper.getHandlerProviders().removeIf(WebMvcRequestHandlerProvider.class::isInstance); }
@Bean
public RequestHandlerProvider customRequestHandlerProvider(Optional
RequestMappingInfo tweakInfo(RequestMappingInfo info) { if (info.getPathPatternsCondition() == null) return info; String[] patterns = info.getPathPatternsCondition().getPatternValues().toArray(String[]::new); return info.mutate().options(new RequestMappingInfo.BuilderConfiguration()).paths(patterns).build(); } }
`
Comment From: eugen-arch
i resolve with spring boot 2.5.12
Comment From: mercado-dacartech
Yo lo corregí instalando el JAR de mi drive SQL (POSTGRES) directamente a mi proyecto quitandolo del pom y agregarlos al built path y agregandolo al compilado.