-
Type:
Regression Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: 7.0.X, Master
-
Fix Version/s: 7.0.0 DXP FP40, 7.0.0 DXP SP7, 7.0.5 CE GA6, 7.0.X, 7.1.0 M2, 7.1.X, Master
-
Component/s: Core Infrastructure > Database Access
-
Branch Version/s:7.0.x
-
Backported to Branch:Committed
-
Story Points:4
-
Fix Priority:3
-
Git Pull Request:
If you want to enable separate read/write data sources, you have to uncomment dynamic-data-source-spring.xml line in portal-ext.properties.
More information, see: https://dev.liferay.com/discover/deployment/-/knowledge_base/7-0/liferay-clustering#read-writer-database-configuration
But from Liferay 7 version, a "cannot resolve reference to bean 'transactionAttributeSource' " error is thrown after enabling that spring xml file.
The root cause of this issue is LPS-54649. All spring configuration files where divided in two groups: spring.infrastructure.configs and spring.configs
dynamic-data-source-spring.xml is included in spring.infrastructure.configs group, but it has a lot of dependencies with beans in spring.configs
Steps to reproduce
- Configure a new Liferay installation using a database, for example mysql:
jdbc.default.driverClassName=com.mysql.jdbc.Driver jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false jdbc.default.username=your-db-user jdbc.default.password=your-db-password
- Start Liferay and verify database tables were created
- Stop Liferay in order to configure read/write setup
- Copy spring and spring.infrastructure section from portal.properties file to your portal-ext.properties:
- Before the changes of this LPS: portal.properties
- After the changes of this LPS: portal.properties
- (You can also get the portal.properties directly from the portal-impl.jar of your Liferay installation)
- Uncomment dynamic-data-source-spring.xml lines. Important: After the changes of this LPS you will see two lines:
- dynamic-data-source-spring.xml
- dynamic-data-source-infrastructure-spring.xml
- Add jdbc.read. and jdbc.write. properties, pointing to same database than jdbc.default.. They should be different databases with replication, but for this issue it is not necessary to setup all that infrastructure.
jdbc.read.driverClassName=com.mysql.jdbc.Driver jdbc.read.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false jdbc.read.username=your-db-user jdbc.read.password=your-db-password jdbc.write.driverClassName=com.mysql.jdbc.Driver jdbc.write.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false jdbc.write.username=your-db-user jdbc.write.password=your-db-password
- Comment jdbc.default properties added in step 1
- Add following lines:
counter.jdbc.prefix=jdbc.write. jdbc.default.liferay.pool.provider=dbcp
- With read/write setup, "default" dataSource won't be used by Liferay, but jdbc driver will try connecting due to 'jdbc.default.validationQuery' configuration (it was added in
LPS-64624). Add following lines to avoid jdbc driver connecting to "default" data source:jdbc.default.validationQuery= jdbc.read.validationQuery=SELECT releaseId FROM Release_ jdbc.write.validationQuery=SELECT releaseId FROM Release_
- Start Liferay
- Expected behavior: Liferay starts successfully
- Wrong behavior: Following error is thrown in log file
com.liferay.portal.spring.context.PortalContextLoaderListener java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamicDataSourceAdvice' defined in class path resource [META-INF/dynamic-data-source-spring.xml]: Cannot resolve reference to bean 'transactionAttributeSource' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionAttributeSource' is defined at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:260) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:585) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
- Expected behavior: Liferay starts successfully
Note: You have more information about configuring this in https://dev.liferay.com/discover/deployment/-/knowledge_base/7-0/liferay-clustering#read-writer-database-configuration
- is caused by
-
LPS-54649 Isolate pure infrastructure beans from the rest of the portal spring context for phased initialization
-
- Closed
-
- is related to
-
LRDOCS-4925 Update read-write DB configuration after LPS-78134 changes
-
- Closed
-