<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=simpor" rel="nofollow">Simon Rydberg</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-2928?redirect=false" rel="nofollow">SPR-2928</a></strong> and commented</p>
<p dir="auto">loading the following application-context, causes the error message at the end.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;!-- ========================= GENERAL DEFINITIONS ========================= --&gt;

&lt;!-- Configurer that replaces ${...} placeholders with values from a properties file --&gt;
&lt;!-- (in this case, JDBC-related settings for the dataSource definition below) --&gt;
&lt;bean id=&quot;propertyConfigurer&quot; class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
    &lt;property name=&quot;location&quot;&gt;
        &lt;value&gt;WEB-INF/jdbc.properties&lt;/value&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Message source for this context, loaded from localized &quot;messages_xx&quot; files --&gt;
&lt;!--
&lt;bean id=&quot;messageSource&quot; class=&quot;org.springframework.context.support.ResourceBundleMessageSource&quot;&gt;
    &lt;property name=&quot;basename&quot;&gt;&lt;value&gt;/WEB-INF/messages&lt;/value&gt;&lt;/property&gt;
&lt;/bean&gt;
--&gt;

&lt;!-- ========================= RESOURCE DEFINITIONS ========================= --&gt;

&lt;!-- Local DataSource that works in any environment --&gt;
&lt;bean id=&quot;dataSource&quot; class=&quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot;&gt;
    &lt;property name=&quot;driverClassName&quot;&gt;
        &lt;value&gt;${jdbc.driverClassName}&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;url&quot;&gt;
        &lt;value&gt;${jdbc.url}&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;username&quot;&gt;
        &lt;value&gt;${jdbc.username}&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;password&quot;&gt;
        &lt;value&gt;${jdbc.password}&lt;/value&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Hibernate SessionFactory --&gt;
&lt;bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot;&gt;
    &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot;/&gt;
    &lt;property name=&quot;mappingResources&quot;&gt;
        &lt;value&gt;library.hbm.xml&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;hibernateProperties&quot;&gt;
        &lt;props&gt;
            &lt;prop key=&quot;hibernate.dialect&quot;&gt;${hibernate.dialect}&lt;/prop&gt;
            &lt;!--				&lt;prop key=&quot;hibernate.show_sql&quot;&gt;true&lt;/prop&gt;--&gt;
            &lt;!--				&lt;prop key=&quot;hibernate.generate_statistics&quot;&gt;true&lt;/prop&gt;--&gt;
            &lt;prop key=&quot;hibernate.query.substitutions&quot;&gt;true 1, false 0, yes 'Y', no 'N'&lt;/prop&gt;
            &lt;prop key=&quot;hibernate.cache.use_second_level_cache&quot;&gt;false&lt;/prop&gt;
            &lt;prop key=&quot;hibernate.cache.use_query_cache&quot;&gt;false&lt;/prop&gt;
        &lt;/props&gt;
    &lt;/property&gt;
    &lt;property name=&quot;eventListeners&quot;&gt;
        &lt;map&gt;
            &lt;entry key=&quot;merge&quot;&gt;
                &lt;bean class=&quot;org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener&quot;/&gt;
            &lt;/entry&gt;
        &lt;/map&gt;
    &lt;/property&gt;
    &lt;property name=&quot;schemaUpdate&quot;&gt;
        &lt;value&gt;true&lt;/value&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --&gt;
&lt;bean id=&quot;transactionManager&quot; class=&quot;org.springframework.orm.hibernate3.HibernateTransactionManager&quot;&gt;
    &lt;property name=&quot;sessionFactory&quot; ref=&quot;sessionFactory&quot;/&gt;
&lt;/bean&gt;

&lt;!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= --&gt;

&lt;!-- Library primary business object: Hibernate implementation --&gt;
&lt;bean id=&quot;libraryTarget&quot; class=&quot;se.transrail.trains.persistence.HibernateLibraryDao&quot;&gt;
    &lt;property name=&quot;sessionFactory&quot;&gt;
        &lt;ref local=&quot;sessionFactory&quot;/&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Transactional proxy for the Library primary business object --&gt;
&lt;bean id=&quot;libraryService&quot; class=&quot;org.springframework.transaction.interceptor.TransactionProxyFactoryBean&quot;&gt;
    &lt;property name=&quot;transactionManager&quot;&gt;
        &lt;ref local=&quot;transactionManager&quot;/&gt;
    &lt;/property&gt;
    &lt;property name=&quot;target&quot;&gt;
        &lt;ref local=&quot;libraryTarget&quot;/&gt;
    &lt;/property&gt;
    &lt;property name=&quot;transactionAttributes&quot;&gt;
        &lt;props&gt;
            &lt;prop key=&quot;get*&quot;&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;
            &lt;prop key=&quot;find*&quot;&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;
            &lt;prop key=&quot;load*&quot;&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;
            &lt;prop key=&quot;store*&quot;&gt;PROPAGATION_REQUIRED&lt;/prop&gt;
            &lt;prop key=&quot;delete*&quot;&gt;PROPAGATION_REQUIRED&lt;/prop&gt;
        &lt;/props&gt;
    &lt;/property&gt;
&lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">&lt;!-- ========================= GENERAL DEFINITIONS ========================= --&gt;

&lt;!-- Configurer that replaces ${...} placeholders with values from a properties file --&gt;
&lt;!-- (in this case, JDBC-related settings for the dataSource definition below) --&gt;
&lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
    &lt;property name="location"&gt;
        &lt;value&gt;WEB-INF/jdbc.properties&lt;/value&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Message source for this context, loaded from localized "messages_xx" files --&gt;
&lt;!--
&lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
    &lt;property name="basename"&gt;&lt;value&gt;/WEB-INF/messages&lt;/value&gt;&lt;/property&gt;
&lt;/bean&gt;
--&gt;

&lt;!-- ========================= RESOURCE DEFINITIONS ========================= --&gt;

&lt;!-- Local DataSource that works in any environment --&gt;
&lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
    &lt;property name="driverClassName"&gt;
        &lt;value&gt;${jdbc.driverClassName}&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="url"&gt;
        &lt;value&gt;${jdbc.url}&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="username"&gt;
        &lt;value&gt;${jdbc.username}&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="password"&gt;
        &lt;value&gt;${jdbc.password}&lt;/value&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Hibernate SessionFactory --&gt;
&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
    &lt;property name="dataSource" ref="dataSource"/&gt;
    &lt;property name="mappingResources"&gt;
        &lt;value&gt;library.hbm.xml&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="hibernateProperties"&gt;
        &lt;props&gt;
            &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
            &lt;!--				&lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;--&gt;
            &lt;!--				&lt;prop key="hibernate.generate_statistics"&gt;true&lt;/prop&gt;--&gt;
            &lt;prop key="hibernate.query.substitutions"&gt;true 1, false 0, yes 'Y', no 'N'&lt;/prop&gt;
            &lt;prop key="hibernate.cache.use_second_level_cache"&gt;false&lt;/prop&gt;
            &lt;prop key="hibernate.cache.use_query_cache"&gt;false&lt;/prop&gt;
        &lt;/props&gt;
    &lt;/property&gt;
    &lt;property name="eventListeners"&gt;
        &lt;map&gt;
            &lt;entry key="merge"&gt;
                &lt;bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/&gt;
            &lt;/entry&gt;
        &lt;/map&gt;
    &lt;/property&gt;
    &lt;property name="schemaUpdate"&gt;
        &lt;value&gt;true&lt;/value&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --&gt;
&lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
    &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
&lt;/bean&gt;

&lt;!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= --&gt;

&lt;!-- Library primary business object: Hibernate implementation --&gt;
&lt;bean id="libraryTarget" class="se.transrail.trains.persistence.HibernateLibraryDao"&gt;
    &lt;property name="sessionFactory"&gt;
        &lt;ref local="sessionFactory"/&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Transactional proxy for the Library primary business object --&gt;
&lt;bean id="libraryService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt;
    &lt;property name="transactionManager"&gt;
        &lt;ref local="transactionManager"/&gt;
    &lt;/property&gt;
    &lt;property name="target"&gt;
        &lt;ref local="libraryTarget"/&gt;
    &lt;/property&gt;
    &lt;property name="transactionAttributes"&gt;
        &lt;props&gt;
            &lt;prop key="get*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;
            &lt;prop key="find*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;
            &lt;prop key="load*"&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;
            &lt;prop key="store*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;
            &lt;prop key="delete*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;
        &lt;/props&gt;
    &lt;/property&gt;
&lt;/bean&gt;
</code></pre></div>
<p dir="auto">Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [/home/simonrydberg/projects/trains/web/WEB-INF/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean; nested exception is org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean<br>
Caused by: org.springframework.orm.hibernate3.HibernateSystemException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean; nested exception is org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean<br>
Caused by: org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean<br>
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.configure(LocalDataSourceConnectionProvider.java:49)<br>
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)<br>
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)<br>
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:397)<br>
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)<br>
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2002)<br>
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:947)<br>
at org.springframework.orm.hibernate3.LocalSessionFactoryBean$3.doInHibernate(LocalSessionFactoryBean.java:934)<br>
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:362)<br>
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:328)<br>
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.updateDatabaseSchema(LocalSessionFactoryBean.java:928)<br>
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterSessionFactoryCreation(LocalSessionFactoryBean.java:826)<br>
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:133)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1024)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)<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.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)<br>
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)<br>
at org.springframework.context.support.FileSystemXmlApplicationContext.&lt;init&gt;(FileSystemXmlApplicationContext.java:89)<br>
at org.springframework.context.support.FileSystemXmlApplicationContext.&lt;init&gt;(FileSystemXmlApplicationContext.java:74)<br>
at se.transrail.trains.domain.railway.RailwayImport2.createDatabaseFromFile(RailwayImport2.java:44)<br>
at se.transrail.trains.domain.railway.RailwayImport2.main(RailwayImport2.java:36)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
at java.lang.reflect.Method.invoke(Method.java:585)<br>
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)</p>
<p dir="auto">I have tried to create a own LocalSessionFactoryBean:</p>
<p dir="auto">public class MyLSFB extends LocalSessionFactoryBean {<br>
protected void postProcessConfiguration(Configuration config) throws HibernateException {<br>
DriverManagerDataSource dataSource = new DriverManagerDataSource();<br>
dataSource.setDriverClassName("org.gjt.mm.mysql.Driver");<br>
dataSource.setUrl("jdbc.url=jdbc:mysql://localhost:3306/database_name?autoReconnect=true");<br>
dataSource.setUsername("root");<br>
dataSource.setPassword("");<br>
this.setDataSource(dataSource);<br>
}</p>
<p dir="auto">and loading it instead of the default LocalSessionFactoryBean. Debugging it, it does come in to the method and creates and sets the datasource, but I still get the error-message...</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0.2</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398073479" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7596" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7596/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7596">#7596</a> Hibernate 3.2.1; HibernateException No local DataSource found for configuration when schemaUpdate is true (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=olivergierke" rel="nofollow">Oliver Drotbohm</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8925?redirect=false" rel="nofollow">SPR-8925</a></strong> and commented</p>
<p dir="auto">Commit <a href="https://fisheye.springsource.org/changelog/spring-framework?cs=4482" rel="nofollow">4482</a> introduced a snippet of code in <code class="notranslate">preparePersistenceUnitInfos()</code> that rejects <code class="notranslate">PersistenceUnit</code> instances with the very same name although the call to <code class="notranslate">postProcessPersistenceUnitInfo(...)</code> might have handled that case correctly. We rely on this behavior with Spring Data JPAs <code class="notranslate">MergingPersistenceUnitManager</code> and got reports (<a href="https://jira.spring.io/browse/DATAJPA-138" rel="nofollow">DATAJPA-138</a>) claiming it's not working with Spring 3.1.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 GA</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/browse/DATAJPA-138" rel="nofollow">DATAJPA-138</a> MergingPersistenceUnitManager doesnt work with Spring 3.1.0 DefaultPersistenceUnitManager (<em><strong>"is depended on by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398118141" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13884" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13884/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13884">#13884</a> Changes in the DefaultPersistenceUnitManager from 3.0 to 3.1 make it impossible to extend it (<em><strong>"is duplicated by"</strong></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/103c648a9240ee56e95cc02bfb4ec4ba848b0746/hovercard" href="https://github.com/spring-projects/spring-framework/commit/103c648a9240ee56e95cc02bfb4ec4ba848b0746"><tt>103c648</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/bdcf480f55a8018690ef28294a36d19a45271243/hovercard" href="https://github.com/spring-projects/spring-framework/commit/bdcf480f55a8018690ef28294a36d19a45271243"><tt>bdcf480</tt></a></p>
<p dir="auto">1 votes, 3 watchers</p>