Recently I had this issue while migrating one Spring Cloud application to a newer version of everything - cloud version to Hoxton.SR3, boot to 2.2.6 and Java from 1.8.0.211 to 13.0.2. My Gateway app was not able to start and I had an exception log on my console.

The error log was the following:

reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.UnsupportedOperationException: getConfigClass() not implemented
Caused by: java.lang.UnsupportedOperationException: getConfigClass() not implemented
	at org.springframework.cloud.gateway.filter.factory.GatewayFilterFactory.getConfigClass(GatewayFilterFactory.java:58) ~[spring-cloud-gateway-core-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at org.springframework.cloud.gateway.support.ConfigurationService$ConfigurableBuilder.doBind(ConfigurationService.java:187) ~[spring-cloud-gateway-core-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at org.springframework.cloud.gateway.support.ConfigurationService$AbstractBuilder.bind(ConfigurationService.java:286) ~[spring-cloud-gateway-core-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	............

After investigation, I found out that after the Spring Cloud update it's required for my custom filter class to implement the getConfigClass() method from the GatewayFilterFactory interface, even though it wasn't necessary before. I didn't have any compilation error, it just crashed in runtime. So, if you had issues with this error, just override the method getConfigClass():

import java.util.Base64;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.GatewayFilterFactory;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;

@Component
public class UploadRouteFilter implements GatewayFilterFactory<UploadRouteFilter.Config> {

  @Override
  public GatewayFilter apply(Config config) {
	return ((exchange, chain) -> {
           // your custom filter code here
	});
	}

	@Override
	public Class<Config> getConfigClass() {
		return Config.class;
	}

	@Override
	public Config newConfig() {
		Config c = new Config();
		return c;
	}

	public static class Config {
	}
}
Pin It

Newsletter

Please enable the javascript to submit this form

Latest