Sunday 15 July 2012

java - Can not apply DaoAuthenticationConfigurer to already built object -



java - Can not apply DaoAuthenticationConfigurer to already built object -

i'm getting exception:

[warn] org.springframework.web.context.support.genericwebapplicationcontext - exception encountered during context initialization - cancelling refresh effort org.springframework.beans.factory.beancreationexception: error creating bean name 'accountresource': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private io.ilopezluna.japanathome.service.userservice io.ilopezluna.japanathome.web.rest.accountresource.userservice; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'userservice': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private org.springframework.security.crypto.password.passwordencoder io.ilopezluna.japanathome.service.userservice.passwordencoder; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'securityconfiguration': injection of autowired dependencies failed; nested exception java.lang.illegalstateexception: cannot apply org.springframework.security.config.annotation.authentication.configurers.userdetails.daoauthenticationconfigurer@54aa5730 built object @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:293) ~[spring-beans-4.0.7.release.jar:4.0.7.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1186) ~[spring-beans-4.0.7.release.jar:4.0.7.release]

you can see more on https://travis-ci.org/ilopezluna/japan-at-home/builds/37866955

this exception thrown during execution of tests. can't reproduce on localhost, build success :s

it took me 2 days, believe i've solved this. in securityconfiguration class had next method:

@configuration @enablewebmvcsecurity @enableglobalmethodsecurity(jsr250enabled=true, prepostenabled=true) public class securityconfiguration extends websecurityconfigureradapter { @autowired public void configureglobal(authenticationmanagerbuilder auth) throws exception { auth.userdetailsservice(authenticationservice); } }

i replaced configureglobal method configure method:

@override public void configure(authenticationmanagerbuilder auth) throws exception { auth.userdetailsservice(authenticationservice); }

and works fine.

according this answer difference using configureglobal allow authenticationmanager global method security or httpsecurity (websecurityconfigureradapter).

as can see above, enabling both web mvc security , global method security. according unit tests, both go on work change, there debate here @ office on whether alter correct (ie, if configuring global method security correctly), or if there problem solution.

we believe root cause of problem type of spring bug, perchance race condition. unlikely seems, problem manifested when added empty class project, didn't matter class's bundle or name was.

java spring spring-security jhipster codeship

No comments:

Post a Comment