Caused by: java.lang.IllegalArgumentException: realmName must be specified




Asked on March 04, 2017
I am creating spring security application. I am implementing BasicAuthenticationEntryPoint. When I run application, I am getting error.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myAuthenticationEntryPoint' defined Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: realmName must be specified
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 28 common frames omitted
Caused by: java.lang.IllegalArgumentException: realmName must be specified
at org.springframework.util.Assert.hasText(Assert.java:168)
at org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint.afterPropertiesSet(BasicAuthenticationEntryPoint.java:54)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 38 common frames omitted





Replied on March 04, 2017
You need to check your code for 

@Override
public void afterPropertiesSet() throws Exception {
setRealmName("TEST REALM");
}


in BasicAuthenticationEntryPoint implementation class.

In security configuration, use

.httpBasic().realmName("TEST REALM")

I hope, it will solve your problem.




Write Answer










©2024 concretepage.com | Privacy Policy | Contact Us