Hi everyone,
currently I am facing a strange problem I am not really sure how to handle this properly.
Just to give you some necessary background regarding our configuration:
- Mixed XML and Java configuration style
- Autowiring is "default"
Due to confidentiality reasons I am just able to post modified code but still the following should demonstrate the problem:
We have a class definition like the following
Furthermore here is the excerpt from our configuration file:Code:@Component @DependsOn("dataSource") class SomeProcedure extends StoredProcedure { .... @Inject @Named("dataSource") // we have many javax.sql.DataSource beans, so we need to qualify here public void init(final DataSource dataSource) { } .... }
This is what the "jndiManager.lookup" signature looks likeCode:<bean id="dataSource" factory-bean="jndiManager" factory-method="lookup"> <constructor-arg><util:constant static-field="...JNDIConstants.ABC"/></constructor-arg> </bean> .... <context:component-scan package"the package which contains SomeProcedure/>
This above configuration runs well under Spring 3.1.1.Code:public Object void lookup(String jndiName) {...}
After an upgrade to Spring 3.1.2 I am runnning into the following
I debugged intensively and might have found the reason for this exception.Code:Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void SomeProcedure.init(javax.sql.DataSource); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
The following change
https://github.com/SpringSource/spri...6448732732c152
introduces a new "Cache by-type lookups in DefaultListableBeanFactory" which is not able to find my "dataSource" dependency.
When "someProcedure" bean is to be autowired the appropriate candidates are resolved by type (javax.sql.DataSource). Unfortunately, the "dataSource" bean does not seem to be cached under the javax.sql.DataSource type key. Instead it is cached under its runtime type (org.apache.commons.dbcp.datasources.SharedPoolDat aSource).
So when I change my dependency from javax.sql.DataSource to SharedPoolDataSource the exception no longer occurs. But I would not want to bind to a concrete implementation type.
Hopefully someone has a helpful idea here.
Would appreciate it very much.
Regards
dokmatik


Reply With Quote