Chaney
Chaney

Reputation: 465

Spring security - Cannot find class DaoAuthenticationProvider

I seem to be stuck in a rut and cannot figure out what is going on. I am currently trying to migrate users from using Sha-256 encryption to Bcyrpt using Spring security. I have looked at this answer and have that class in place however I am getting the following error on Tomcat startup:

     ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:307) - Context initialization failed
    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class   [org.springframework.security.authentication.dao.DaoAuthenticationProvider<200c><200b>] for  bean with name 'customAuthenticationProvider' defined in file  [/var/lib/tomcat7/webapps/UKExtranet/WEB-INF/classes/META-INF/spring/applicationContext-security.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.security.authentication.dao.DaoAuthenticationProvider<200c><200b>

Although this seems straightforward enough(ClassNotFoundException) the class is definitely there, I have checked and even gotten a co worker to check in case I was going mad, he also said it was there.

Below is the relevant part of my applicationContext-security.xml file:

     <bean id='bCryptPasswordEncoder'
    class='co.uk.thehartford.life.security.passwordencoder.MigrateUsersPasswordEncoder' />

<security:authentication-manager>
    <security:authentication-provider
        user-service-ref="userDetailsService">
        <security:password-encoder ref="bCryptPasswordEncoder" />
    </security:authentication-provider>
</security:authentication-manager>


<bean id="userDetailsService" class="co.uk.thehartford.life.security.dao.ExtranetJdbcDaoImpl">
    <property name="dataSource" ref="dataSource" />
</bean>

<bean id="customAuthenticationProvider"
    class="org.springframework.security.authentication.dao.DaoAuthenticationProvider‌​">
    <property name="userDetailsService" ref="userDetailsService" />
    <property name="passwordEncoder" ref="bCryptPasswordEncoder" />
</bean>

I do not know what could be causing this error. Anyone have any ideas? Any help is greatly appreciated. Thank you, any further information is needed just let me know and I will post what I can.

I should also point out I am quite new to Spring, so I could be missing something quite simple.

Upvotes: 0

Views: 1425

Answers (1)

Shaun the Sheep
Shaun the Sheep

Reputation: 22742

It looks like the characters are there (and also copied to your question, Firefox displays that line strangely).

If I run:

 curl http://stackoverflow.com/questions/27544456/spring-security-cannot-find-class-daoauthenticationprovider  | grep --context=2 class=\"org.springframework.security.authentication.dao.DaoAuthenticationProvider | less

I get:

&lt;bean id="customAuthenticationProvider"
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider<U+200C><U+200B>"&gt;
&lt;property name="userDetailsService" ref="userDetailsService" /&gt;
&lt;property name="passwordEncoder" ref="bCryptPasswordEncoder" /&gt;

So they certainly appear to be there in what you've posted above. Try deleting the line and rewriting it again as holmis83 suggests.

Upvotes: 1

Related Questions