Issue 1:
Simon Rydberg opened SPR-2928 and commented

loading the following application-context, causes the error message at the end.

<!-- ========================= GENERAL DEFINITIONS ========================= -->

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

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

<!-- ========================= RESOURCE DEFINITIONS ========================= -->

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

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

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

<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->

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

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

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

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

Caused by: org.hibernate.HibernateException: No local DataSource found for configuration - dataSource property must be set on LocalSessionFactoryBean

at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.configure(LocalDataSourceConnectionProvider.java:49)

at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)

at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)

at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:397)

at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)

at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2002)

at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:947)

at org.springframework.orm.hibernate3.LocalSessionFactoryBean$3.doInHibernate(LocalSessionFactoryBean.java:934)

at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:362)

at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:328)

at org.springframework.orm.hibernate3.LocalSessionFactoryBean.updateDatabaseSchema(LocalSessionFactoryBean.java:928)

at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterSessionFactoryCreation(LocalSessionFactoryBean.java:826)

at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:133)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1024)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)

at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:89)

at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:74)

at se.transrail.trains.domain.railway.RailwayImport2.createDatabaseFromFile(RailwayImport2.java:44)

at se.transrail.trains.domain.railway.RailwayImport2.main(RailwayImport2.java:36)

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:585)

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

I have tried to create a own LocalSessionFactoryBean:

public class MyLSFB extends LocalSessionFactoryBean {

protected void postProcessConfiguration(Configuration config) throws HibernateException {

DriverManagerDataSource dataSource = new DriverManagerDataSource();

dataSource.setDriverClassName("org.gjt.mm.mysql.Driver");

dataSource.setUrl("jdbc.url=jdbc:mysql://localhost:3306/database_name?autoReconnect=true");

dataSource.setUsername("root");

dataSource.setPassword("");

this.setDataSource(dataSource);

}

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...

Affects: 2.0.2

Issue Links:

#7596 Hibernate 3.2.1; HibernateException No local DataSource found for configuration when schemaUpdate is true ("duplicates")

Issue 2:
Oliver Drotbohm opened SPR-8925 and commented

Commit 4482 introduced a snippet of code in preparePersistenceUnitInfos() that rejects PersistenceUnit instances with the very same name although the call to postProcessPersistenceUnitInfo(...) might have handled that case correctly. We rely on this behavior with Spring Data JPAs MergingPersistenceUnitManager and got reports (DATAJPA-138) claiming it's not working with Spring 3.1.

Affects: 3.1 GA

Issue Links:

DATAJPA-138 MergingPersistenceUnitManager doesnt work with Spring 3.1.0 DefaultPersistenceUnitManager ("is depended on by")

#13884 Changes in the DefaultPersistenceUnitManager from 3.0 to 3.1 make it impossible to extend it ("is duplicated by")

Referenced from: commits 103c648, bdcf480

1 votes, 3 watchers