Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to customize user-service in Spring Security 3.05
    primarykey
    data
    text
    <p>Please help with the following error that I get with Spring Security 3.05 and Tomcat7.0. I am new to spring security and am using the below tutorial: Simple web application with Spring Security: <a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-6/" rel="nofollow">http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-6/</a></p> <p>Here is the error:</p> <pre><code>SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in ServletContext resource [/WEB-INF/applicationContext-security.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.springframework.security.core.userdetails.memory.InMemoryDaoImpl' to required type 'org.springframework.security.userdetails.UserDetailsService' for property 'userDetailsService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.security.core.userdetails.memory.InMemoryDaoImpl] to required type [org.springframework.security.userdetails.UserDetailsService] for property 'userDetailsService': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.springframework.security.core.userdetails.memory.InMemoryDaoImpl' to required type 'org.springframework.security.userdetails.UserDetailsService' for property 'userDetailsService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.security.core.userdetails.memory.InMemoryDaoImpl] to required type [org.springframework.security.userdetails.UserDetailsService] for property 'userDetailsService': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:471) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1363) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1322) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) ... 19 more Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.security.core.userdetails.memory.InMemoryDaoImpl] to required type [org.springframework.security.userdetails.UserDetailsService] for property 'userDetailsService': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:291) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:155) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:461) ... 23 more </code></pre> <p>My spring security config and listed below:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"&gt; &lt;!--&lt;global-method-security secured-annotations="disabled"&gt; &lt;/global-method-security&gt; &lt;http auto-config="true"&gt; &lt;intercept-url pattern="/login.jsp" filters="none" /&gt; &lt;intercept-url pattern="/**" access="ROLE_USER" /&gt; &lt;form-login login-page="/login.jsp" default-target-url="/home.htm" always-use-default-target="false" authentication-failure-url="/login.jsp?authfailed=true"/&gt; &lt;logout invalidate-session="true" logout-url="/logout.htm" logout-success-url="/login.jsp?loggedout=true"/&gt; &lt;session-management session-fixation-protection="newSession"&gt; &lt;concurrency-control max-sessions="1" error-if-maximum-exceeded="true"/&gt; &lt;/session-management&gt; &lt;/http&gt; &lt;authentication-manager&gt; &lt;authentication-provider&gt; &lt;user-service id="userDetailsService"&gt; &lt;user name="username" password="password" authorities="ROLE_USER, ROLE_ADMIN" /&gt; &lt;user name="test" password="test" authorities="ROLE_USER" /&gt; &lt;/user-service&gt; &lt;/authentication-provider&gt; &lt;/authentication-manager&gt;--&gt; &lt;beans:bean id="sessionRegistry" class="org.springframework.security.concurrent.SessionRegistryImpl" /&gt; &lt;beans:bean id="defaultConcurrentSessionController" class="org.springframework.security.concurrent.ConcurrentSessionControllerImpl"&gt; &lt;beans:property name="sessionRegistry" ref="sessionRegistry" /&gt; &lt;beans:property name="exceptionIfMaximumExceeded" value="true" /&gt; &lt;/beans:bean&gt; &lt;beans:bean id="daoAuthenticationProvider" class="org.springframework.security.providers.dao.DaoAuthenticationProvider"&gt; &lt;beans:property name="userDetailsService" ref="userDetailsService" /&gt; &lt;beans:property name="hideUserNotFoundExceptions" value="false" /&gt; &lt;/beans:bean&gt; &lt;beans:bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager"&gt; &lt;beans:property name="providers"&gt; &lt;beans:list&gt; &lt;beans:ref local="daoAuthenticationProvider" /&gt; &lt;/beans:list&gt; &lt;/beans:property&gt; &lt;beans:property name="sessionController" ref="defaultConcurrentSessionController" /&gt; &lt;/beans:bean&gt; &lt;beans:bean id="customAuthenticationProcessingFilter" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter"&gt; &lt;beans:property name="defaultTargetUrl" value="/home.htm" /&gt; &lt;beans:property name="authenticationManager" ref="authenticationManager" /&gt; &lt;beans:property name="authenticationFailureUrl" value="/login.jsp?authfailed=true" /&gt; &lt;beans:property name="allowSessionCreation" value="true" /&gt; &lt;/beans:bean&gt; &lt;global-method-security secured-annotations="disabled"&gt; &lt;/global-method-security&gt; &lt;beans:bean id="myAuthenticationEntryPoint" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint"&gt; &lt;beans:property name="loginFormUrl" value="/login.jsp" /&gt; &lt;/beans:bean&gt; &lt;http entry-point-ref="myAuthenticationEntryPoint" auto-config="false"&gt; &lt;intercept-url pattern="/login.jsp" filters="none" /&gt; &lt;intercept-url pattern="/admin.htm" access="ROLE_ADMIN" /&gt; &lt;intercept-url pattern="/**" access="ROLE_USER" /&gt; &lt;logout invalidate-session="true" logout-url="/logout.htm" logout-success-url="/login.jsp?loggedout=true" /&gt; &lt;custom-filter position="FORM_LOGIN_FILTER" ref="customAuthenticationProcessingFilter"/&gt; &lt;/http&gt; &lt;authentication-manager&gt; &lt;authentication-provider&gt; &lt;user-service id="userDetailsService"&gt; &lt;user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" /&gt; &lt;user name="username" password="password" authorities="ROLE_USER" /&gt; &lt;user name="test" password="test" authorities="ROLE_USER" /&gt; &lt;/user-service&gt; &lt;/authentication-provider&gt; &lt;/authentication-manager&gt; &lt;/beans:beans&gt; </code></pre> <p>Regards, Nazir</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload