We have an application using Spring MVC. We recently changed our build process to use Maven 3.0.5 instead of Maven 3.2.3 (there is not a relevant reason for this) and started experiencing exceptions deploying into WebLogic.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.springframework.security.authentication.AuthenticationManager com.es3.ers.controller.AuthenticationController.authManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.es3.ers.filter.AuthenticationTokenProcessingFilter com.es3.ers.config.SecurityConfig.authenticationTokenProcessingFilter; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationTokenProcessingFilter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.security.authentication.AuthenticationManager com.es3.ers.filter.AuthenticationTokenProcessingFilter.authenticationManager; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'authenticationManager': Requested bean is currently in creation: Is there an unresolvable circular reference?
Some research yielded an issue in our code which we did resolve to get the application working again, but it really got me thinking as to why the Maven version would affect Spring in this way.
I compared the versions built on 3.0.5 and 3.2.3 and other than the timestamps in the MANIFEST file there were no differences. I then looked at the structure of the archive and noticed that the 3.0.5 version had these three (related to the bug) files:
$ unzip -t ers.war | grep -E "(AuthenticationController|AuthenticationTokenProcessingFilter|SecurityConfig)\.class"
testing: WEB-INF/classes/com/es3/ers/controller/AuthenticationController.class OK
testing: WEB-INF/classes/com/es3/ers/filter/AuthenticationTokenProcessingFilter.class OK
testing: WEB-INF/classes/com/es3/ers/config/SecurityConfig.class OK
The 3.2.3 had these same three files:
$ unzip -t ers.war | grep -E "(AuthenticationController|AuthenticationTokenProcessingFilter|SecurityConfig)\.class"
testing: WEB-INF/classes/com/es3/ers/filter/AuthenticationTokenProcessingFilter.class OK
testing: WEB-INF/classes/com/es3/ers/controller/AuthenticationController.class OK
testing: WEB-INF/classes/com/es3/ers/config/SecurityConfig.class OK
You will notice that AuthenticationController is before AuthenticationTokenProcessingFilter from Maven 3.0.5 and in 3.2.3 they are opposite. Out of ideas I extracted the files out of the 3.0.5 archive, removed them and added them back so they were in the same order:
$ unzip ers.war WEB-INF/classes/com/es3/ers/controller/AuthenticationController.class WEB-INF/classes/com/es3/ers/config/SecurityConfig.class
$ zip -d ers.war WEB-INF/classes/com/es3/ers/controller/AuthenticationController.class WEB-INF/classes/com/es3/ers/config/SecurityConfig.class
$ zip -ru ers.war WEB-INF/classes/com/es3/ers/controller/AuthenticationController.class WEB-INF/classes/com/es3/ers/config/SecurityConfig.class
$ unzip -t ers.war | grep -E "(AuthenticationController|AuthenticationTokenProcessingFilter|SecurityConfig)\.class"
testing: WEB-INF/classes/com/es3/ers/filter/AuthenticationTokenProcessingFilter.class OK
testing: WEB-INF/classes/com/es3/ers/controller/AuthenticationController.class OK
testing: WEB-INF/classes/com/es3/ers/config/SecurityConfig.class OK
After the manipulation of the files in the archive we were able to successfully deploy to WebLogic. The fix is obviously to correct the bug in our code, but what is happening here? I counted this as Maven related because it is obviously building the WAR in a very consistent order per version, so it was interesting to me that it changed. Maven 3.0.5 and 3.2.3 are using the same version of the Maven WAR plugin.