-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Qualifier no longer works in 3.0 [SPR-5355] #10028
Comments
Juergen Hoeller commented It would be great if you could isolate this into a unit test... Our general qualifier unit tests still pass in 3.0 M1. Juergen |
Scott Murphy commented This appears to just be happening with Properties files only. If I remove the properties from the constructor, the qualifier still works for my datasource. |
Scott Murphy commented is systemProperties new to Spring 3? If so, that is probably what is causing the confusion. |
Scott Murphy commented Okay, I created a Unit test for you that fails: SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@193a66f] to prepare test instance [test.QualifierTest@93d6bc] |
Scott Murphy commented I have attached the unit test |
Scott Murphy commented JUnit test that shows |
Scott Murphy commented Hey Juergen, Once you fix this, am I going to have to wait for the M2 release to use it? Or is there a 3.0.0.M2-SNAPSHOT release I can get access too via Maven? |
Juergen Hoeller commented This is resolved for M2 now: Any singletons registered, including default singletons such as "systemProperties", will be fully matched according to their qualifiers as well - and not simply considered a default match like before. Juergen |
Scott Murphy opened SPR-5355 and commented
The following code works with Spring 2.5.x but does not work with 3.0 M1
Xml:
<util:properties id="clientProperties" location="classpath:/com/pictage/client/client.properties"/>
Java Code:
Exception:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'directoryService' defined in file [C:\Users\smurphy\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\photographer\WEB-INF\classes\com\pictage\directory\bus\DirectoryService.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.pictage.directory.dao.DirectoryDao]: : Error creating bean with name 'directoryDaoJdbc' defined in file [C:\Users\smurphy\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\photographer\WEB-INF\classes\com\pictage\directory\dao\jdbc\DirectoryDaoJdbc.class]: Unsatisfied dependency expressed through constructor argument with index 3 of type [java.util.Properties]: : No unique bean of type [java.util.Properties] is defined: expected single matching bean but found 2: [clientProperties, systemProperties]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [java.util.Properties] is defined: expected single matching bean but found 2: [clientProperties, systemProperties]; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'directoryDaoJdbc' defined in file [C:\Users\smurphy\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\photographer\WEB-INF\classes\com\pictage\directory\dao\jdbc\DirectoryDaoJdbc.class]: Unsatisfied dependency expressed through constructor argument with index 3 of type [java.util.Properties]: : No unique bean of type [java.util.Properties] is defined: expected single matching bean but found 2: [clientProperties, systemProperties]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [java.util.Properties] is defined: expected single matching bean but found 2: [clientProperties, systemProperties]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:582)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:922)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:833)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:442)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:411)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:382)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:271)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:268)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:470)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:719)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:378)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:254)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:198)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'directoryDaoJdbc' defined in file [C:\Users\smurphy\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\photographer\WEB-INF\classes\com\pictage\directory\dao\jdbc\DirectoryDaoJdbc.class]: Unsatisfied dependency expressed through constructor argument with index 3 of type [java.util.Properties]: : No unique bean of type [java.util.Properties] is defined: expected single matching bean but found 2: [clientProperties, systemProperties]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [java.util.Properties] is defined: expected single matching bean but found 2: [clientProperties, systemProperties]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:582)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:922)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:833)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:442)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:411)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:382)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:271)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:268)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:721)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:660)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:612)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:575)
... 32 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [java.util.Properties] is defined: expected single matching bean but found 2: [clientProperties, systemProperties]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:671)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:612)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:575)
... 47 more
Affects: 3.0 M1
Attachments:
Referenced from: commits 5a04ed5
The text was updated successfully, but these errors were encountered: