0

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.

Community
  • 1
  • 1
Chaney
  • 455
  • 1
  • 7
  • 20
  • 1
    The `<200c><200b>` makes me wonder if you have some trash character in your config? – holmis83 Dec 18 '14 at 14:50
  • I thought about that as well but in the application-securityContext there is no space after the class name so if there is a junk character there or being inserted I do not know how to check – Chaney Dec 18 '14 at 14:53
  • 1
    Have you tried to delete and rewrite that particular line? – holmis83 Dec 18 '14 at 15:30
  • Now that I think of it, I have only copied and pasted it, not deleted and rewritten, I shall try that now. – Chaney Dec 19 '14 at 08:47
  • That was exactly the problem holmis83, thank for the help! – Chaney Dec 19 '14 at 09:30

1 Answers1

1

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.

Shaun the Sheep
  • 22,353
  • 1
  • 72
  • 100
  • That was exactly the problem! A full day wasted over something like that! Thanks for the help! – Chaney Dec 19 '14 at 09:30