<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=casey.hadden" rel="nofollow">Casey Hadden</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7204?redirect=false" rel="nofollow">SPR-7204</a></strong> and commented</p>
<p dir="auto">AbstractApplicationEventMulticaster has two getApplicationListeners methods. The no parameter method will return duplicate listeners in its list while the one subsetting by event type does not.</p>
<p dir="auto">It appears that when the default ListenerRetriever class is iterating over the listenerBeanNames the add call should be protected by a !allListeners.contains(listener) check like the event subset method is.</p>
<p dir="auto">Attached is a zip file which shows the two listeners printed from the no parameter method while only one is printed from the event type method.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 GA, 3.0.1, 3.0.2</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/16556/AbstractApplicationEventMulticaster.zip" rel="nofollow">AbstractApplicationEventMulticaster.zip</a> (<em>1.41 kB</em>)</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/738d84f75c21873bcf6e80bcb64cd92f5da28d8e/hovercard" href="https://github.com/spring-projects/spring-framework/commit/738d84f75c21873bcf6e80bcb64cd92f5da28d8e"><tt>738d84f</tt></a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=voidmain" rel="nofollow">Brian Pontarelli</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-2651?redirect=false" rel="nofollow">SPR-2651</a></strong> and commented</p>
<p dir="auto">I previously had a configuration that was working fine through all 2.0 releases until I recently upgrade from M4 to RC4. This no longer works. Here is the stack trace:</p>
<p dir="auto">org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource' defined in file [/home/brian/dev/java/naymz/web/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'messageDAO' while setting bean property 'messageDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageDAO' defined in file [/home/brian/dev/java/naymz/web/WEB-INF/classes/applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required<br>
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageDAO' defined in file [/home/brian/dev/java/naymz/web/WEB-INF/classes/applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required<br>
Caused by: java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required<br>
at org.springframework.orm.hibernate3.support.HibernateDaoSupport.checkDaoConfig(HibernateDaoSupport.java:112)<br>
at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:957)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:924)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:415)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)<br>
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)<br>
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:850)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:624)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:411)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)<br>
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:646)<br>
at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:455)<br>
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:336)<br>
at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:92)<br>
at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:77)<br>
at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:138)<br>
at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:125)<br>
at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:104)<br>
at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:75)<br>
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)<br>
at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)</p>
<p dir="auto">This configuration for the SessionFactory (which is a FactoryBean) and the DAO are:</p>
<p dir="auto">&lt;bean id="sessionFactory" parent="abstractSessionFactory"&gt;<br>
&lt;property name="hibernateProperties"&gt;<br>
&lt;props&gt;<br>
&lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/prop&gt;<br>
&lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.EhCacheProvider&lt;/prop&gt;<br>
&lt;prop key="hibernate.cache.use_second_level_cache"&gt;true&lt;/prop&gt;<br>
&lt;prop key="hibernate.cache.use_query_cache"&gt;true&lt;/prop&gt;<br>
&lt;prop key="hibernate.show_sql"&gt;false&lt;/prop&gt;<br>
&lt;prop key="hibernate.current_session_context_class"&gt;thread&lt;/prop&gt;<br>
&lt;prop key="hibernate.cglib.use_reflection_optimizer"&gt;true&lt;/prop&gt;<br>
&lt;/props&gt;<br>
&lt;/property&gt;<br>
&lt;/bean&gt;<br>
&lt;bean id="abstractSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" abstract="true"&gt;<br>
&lt;property name="dataSource" ref="dataSource"/&gt;<br>
&lt;property name="entityInterceptor"&gt;<br>
&lt;bean class="com.naymz.dao.UpsertInterceptor"/&gt;<br>
&lt;/property&gt;<br>
&lt;property name="annotatedClasses"&gt;<br>
&lt;list&gt;<br>
(snip)<br>
&lt;/list&gt;<br>
&lt;/property&gt;<br>
&lt;/bean&gt;<br>
&lt;bean id="messageDAO" class="com.naymz.dao.cms.MessageDAOImpl" autowire="autodetect"/&gt;</p>
<p dir="auto">The configuration for the messageSource bean is:</p>
<p dir="auto">&lt;bean id="messageSource" class="com.naymz.cms.NaymzMessageSource"&gt;<br>
&lt;property name="useCodeAsDefaultMessage" value="false"/&gt;<br>
&lt;property name="alwaysUseMessageFormat" value="false"/&gt;<br>
&lt;property name="messageDAO" ref="messageDAO"/&gt;<br>
&lt;property name="siteDAO" ref="siteDAO"/&gt;<br>
&lt;/bean&gt;<br>
The issue appears to be that since there is an abstract FactoryBean, the messageDAO is not being injected based on type. My DAO has no dependencies. The superclass of my DAO with a dependency is org.springframework.orm.hibernate3.support.HibernateDaoSupport, which has a setter for a org.hibernate.SessionFactory. I have tried changing the autowire to byType with no luck. byName works but forces huge amounts of changes all over my configuration so that everything is byName and lines up correctly. For whatever reason, the container can no longer determine that I only have a single bean defined of type org.hibernate.SessionFactory and inject that. So, it seems that autowire autodetect and byType are now broken, probably due to the abstract FactoryBean stuff.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0 RC4</p>