Last active
December 25, 2015 18:39
-
-
Save vunb/7022551 to your computer and use it in GitHub Desktop.
Lỗi xảy ra khi load 2 file config xml có khai báo beans trùng nhau (conflict Beans):
- Thông báo lỗi: org.hibernate.HibernateException: merge is not valid without active transaction
hoặc lỗi: org.hibernate.HibernateException: No Session found for current thread <br/>
Ref: http://stackoverflow.com/questions/15488701/spring-3-with-hibernate-4-unit…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> | |
<import resource="classpath*:applicationContext-service.xml"/> | |
<import resource="classpath*:applicationContext-dao.xml"/> | |
<import resource="classpath*:applicationContext.xml"/> | |
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> | |
<property name="ignoreUnresolvablePlaceholders" value="true"/> | |
<property name="locations"> | |
<list> | |
<value>classpath:jdbc.properties</value> | |
</list> | |
</property> | |
</bean> | |
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> | |
<property name="driverClassName" value="${jdbc.driverClassName}"/> | |
<property name="url" value="${jdbc.url}"/> | |
<property name="username" value="${jdbc.username}"/> | |
<property name="password" value="${jdbc.password}"/> | |
</bean> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:context="http://www.springframework.org/schema/context" | |
xmlns:tx="http://www.springframework.org/schema/tx" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd | |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd | |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd" | |
default-lazy-init="true"> | |
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> | |
<property name="ignoreUnresolvablePlaceholders" value="true"/> | |
<property name="locations"> | |
<list> | |
<!-- <value>classpath:jdbc.properties</value>--> | |
<!-- <value>classpath:mail.properties</value> --> | |
<!-- <value>classpath:hibernate.properties</value> --> | |
<!-- <value>classpath:hibernate.cfg.xml</value> --> | |
</list> | |
</property> | |
</bean> | |
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> | |
<property name="driverClassName" value="oracle.jdbc.OracleDriver"/> | |
<property name="url" value="jdbc:oracle:thin:@x.x.x.x:1521:vtdb"/> | |
<property name="username" value="wnms_config_test"/> | |
<property name="password" value="xxxxxxxxxxxxxxxx"/> | |
</bean> | |
<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/> | |
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/> | |
<!-- Hibernate SessionFactory --> | |
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" destroy-method="destroy"> | |
<property name="dataSource" ref="dataSource"/> | |
<property name="configLocation" value="classpath:hibernate.cfg.xml"/> | |
<property name="hibernateProperties"> | |
<props> | |
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> | |
<prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop> | |
<prop key="hibernate.cache.use_second_level_cache">true</prop> | |
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> | |
<!-- Hibernate Search index directory --> | |
<prop key="hibernate.search.default.indexBase">${app.search.index.basedir}</prop> | |
<!--<prop key="hibernate.current_session_context_class">thread</prop>--> | |
</props> | |
<!-- Turn batching off for better error messages under PostgreSQL --> | |
<!-- hibernate.jdbc.batch_size=0 --> | |
</property> | |
</bean> | |
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> | |
<!-- Enable annotation style of managing transactions --> | |
<!--<tx:annotation-driven />--> | |
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> | |
<property name="sessionFactory" ref="sessionFactory"/> | |
<!--<property name="dataSource" ref="dataSource"/>--> | |
</bean> | |
<!-- Transaction: enable annotation-driven transaction --> | |
<!--Put @Transactional on service impl instead of service interface--> | |
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> | |
<!--<tx:annotation-driven transaction-manager="transactionManager" />--> | |
<!-- Activates scanning of @Autowired --> | |
<context:annotation-config/> | |
<!-- Activates scanning of @Repository --> | |
<context:component-scan base-package="org.appfuse.dao"/> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jdbc.driverClassName=oracle.jdbc.OracleDriver | |
jdbc.url=jdbc:oracle:thin:@X.X.X.X:1521:vtdb | |
jdbc.username=wnms_config_test | |
jdbc.password=xxxxxxxxxxxxxxxx | |
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect | |
# Needed by Hibernate3 Maven Plugin defined in pom.xml | |
hibernate.connection.driver_class=oracle.jdbc.OracleDriver | |
hibernate.connection.url=jdbc:oracle:thin:@X.X.X.X:1521:vtdb | |
hibernate.connection.username=wnms_config_test | |
hibernate.connection.password=xxxxxxxxxxxxxxxx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment