Skip to content

BE: Auth: Error on startup with non-prod profiles #757

@Haarolean

Description

@Haarolean
          @Haarolean After merging https://github.com/kafbat/kafka-ui/commit/85330e88372653274dce1b70effc1c506a66bdac, new tests fail with the error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configureLdap' defined in class path resource [io/kafbat/ui/config/auth/LdapSecurityConfig.class]: Failed to instantiate [org.springframework.security.web.server.SecurityWebFilterChain]: Factory method 'configureLdap' threw exception with message: java.io.FileNotFoundException: class path resource [static/index.html] cannot be opened because it does not exist
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1355)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1185)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1689)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1653)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeanCollection(DefaultListableBeanFactory.java:1543)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1511)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1392)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:888)
	... 128 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.server.SecurityWebFilterChain]: Factory method 'configureLdap' threw exception with message: java.io.FileNotFoundException: class path resource [static/index.html] cannot be opened because it does not exist
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:178)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
	... 145 common frames omitted
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: class path resource [static/index.html] cannot be opened because it does not exist
	at io.kafbat.ui.util.StaticFileWebFilter.<init>(StaticFileWebFilter.java:35)
	at io.kafbat.ui.util.StaticFileWebFilter.<init>(StaticFileWebFilter.java:26)
	at io.kafbat.ui.config.auth.LdapSecurityConfig.configureLdap(LdapSecurityConfig.java:157)
	at io.kafbat.ui.config.auth.LdapSecurityConfig$$SpringCGLIB$$0.CGLIB$configureLdap$5(<generated>)
	at io.kafbat.ui.config.auth.LdapSecurityConfig$$SpringCGLIB$$FastClass$$1.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:348)
	at io.kafbat.ui.config.auth.LdapSecurityConfig$$SpringCGLIB$$0.configureLdap(<generated>)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146)
	... 146 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [static/index.html] cannot be opened because it does not exist
	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:215)
	at io.kafbat.ui.util.ResourceUtil.readAsString(ResourceUtil.java:16)
	at io.kafbat.ui.util.StaticFileWebFilter.<init>(StaticFileWebFilter.java:33)
	... 156 common frames omitted

In general, this can be fixed by building the project mvnw clean install -DskipTests -Pprod before running the tests.
I checked it locally - the tests pass.
What do you think about this?

Originally posted by @wernerdv in #726 (comment)

Metadata

Metadata

Assignees

Labels

area/authApp authentication related issuesscope/backendRelated to backend changesstatus/triage/completedAutomatic triage completedtype/bugSomething isn't working

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions