Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

because "this.condition" is null #28794

Closed
weir2010 opened this issue Nov 24, 2021 · 18 comments
Closed

because "this.condition" is null #28794

weir2010 opened this issue Nov 24, 2021 · 18 comments
Labels
for: external-project For an external project and not something we can fix

Comments

@weir2010
Copy link

weir2010 commented Nov 24, 2021

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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 24, 2021
@weir2010
Copy link
Author

springboot 2.5.7 is ok

@snicoll
Copy link
Member

snicoll commented Nov 24, 2021

This is a springfox problem that should be reported against the relevant project. See also #28769

@snicoll snicoll closed this as completed Nov 24, 2021
@snicoll snicoll added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 24, 2021
@wilkinsona
Copy link
Member

springfox/springfox#3462 is already tracking this on the Springfox side.

@weir2010
Copy link
Author

weir2010 commented Nov 29, 2021

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

@wilkinsona
Copy link
Member

@weir2010 Can you please provide some more context for your comment? I don't see the connection between MQTT and web request path parsing.

@weir2010
Copy link
Author

weir2010 commented Nov 30, 2021

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

}

@philwebb
Copy link
Member

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

@weir2010
Copy link
Author

I found the problem. It's really swagger ok

@JuKu
Copy link

JuKu commented Dec 15, 2021

I have the same problem with the newest Spring version 2.6.1 and springfox-swagger2 version 3.0.0 . Is there a workaround?

@notforward
Copy link

same problem as mentioned above

@rcbandit111
Copy link

Any update? Any plans to release a fixed version?

@snicoll
Copy link
Member

snicoll commented Dec 24, 2021

Please read the issue history before commenting. This is a springfox issue and nothing we can do here.

@segomin
Copy link

segomin commented Jan 7, 2022

springfox/springfox#3462 (comment) helped me btw.

@mert-unsal

This comment was marked as outdated.

@wilkinsona

This comment was marked as outdated.

@amitbd1508

This comment was marked as off-topic.

@eugen-arch
Copy link

i resolve with spring boot 2.5.12

@mercado-dacartech

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests