This website uses cookies to ensure you get the best experience. Learn More.
Liferay migration 6.2 to 7.1
For Liferay migration to 7.1 I have created a demo project (with custom theme, layout, portlet and hook), and also configured a set of pages and web contents on portal.
Original 6.2 code is available in repository: https://bitbucket.org/aimprosoft/liferay-migration-6.2-ce-ga4
Below is description of modules to be migrated:
Remove unused objects
To speed up migration process, and also to increase the performance of portal after migration - we need to remove unused objects (for example, Layouts, Users, Documents, etc.). Also we need to remove intermediate versions for web contents and documents. For example, if we have updated web content 3 times - we have 4 different versions:
, but we need only the latest one (1.3). Three previous ones can be removed.
Remove duplicated structure names
If you have different web content structures in your portal - there is possibility, that different structured have fields with the same name. It's OK for Liferay 6.2, but migration to 7.x will fail.
First of all, download Liferay 7.1:
There are different tools/plugins to work with Liferay 7.x. It depends on which IDE you work with, which tool to use. Personally I prefer Intellij IDEA. If you use IDEA also - you can install Liferay IntelliJ Plugin for it. It allows you to setup Liferay worskspace, configure Liferay server, create different modules from templates, deploy them, etc.
For those ones, who work in Eclipse - there is Liferay Developer Studio and Liferay IDE. Although I'm not a fan of Eclipse, need to admin that it has better integration with Liferay and more opportunities, even for code migration process. Will touch this topic later.
Prepare database for migration
Create a separate database for migration in MySQL:
create database lr_migration_dxp character set utf8;
Create a database dump from 6.2 database and load it to new one:
mysqldump -uroot -p1 lr_migration > lr_migration.sql mysql -uroot -p1 lr_migration_dxp < lr_migration.sql
Create file 'portal-setup-wizard.properties' with the DB connection properties inside:
jdbc.default.driverClassName=com.mysql.jdbc.Driver jdbc.default.url=jdbc:mysql://localhost:3306/lr_migration_dxp jdbc.default.username=root jdbc.default.password=1
Note: DO NOT START Liferay instance right now. Otherwise, you'll get error like this:
2018-09-26 13:44:57.402 ERROR [main][MainServlet:273] java.lang.RuntimeException: You must first upgrade to Liferay Portal 7100 java.lang.RuntimeException: You must first upgrade to Liferay Portal 7100 at com.liferay.portal.tools.DBUpgrader.checkRequiredBuildNumber(DBUpgrader.java:87)
(see errors list in the end)
indexReadOnly="true"
autoUpgrade="false"
(it should be 62xx before you run the upgrade)
./db_upgrade.sh -l "db_upgrade.log"
This will update Liferay core, and output this message after finishing: After this run
upgrade:executeAll
command in appeared Gogo Shell.
Modify file
indexReadOnly="false"
Start Liferay and ensure, that database has been updated successfully. Code migration will take place in next chapter.
Database migration should be finished at this point.
Although there is not to much steps to perform the migration - it still requires a lot of manual work with configuration files, creation/restore dumps, copying files, etc. And if there are any errors during migration - you need to perform all these actions again and again from the beginning.
To automate this process I have created a bash script, which performs all the actions above. It's available here:
https://bitbucket.org/aimprosoft/liferay-migration-ce-7.1.0-ga1/src/master/scripts/migrate.sh
You just need to specify your properties:
######## Properties ################ #MySQL db_user=root db_password=1 #LR 6.2 lr62_path=/home/vitaliy/Work/Liferay/migration/liferay-6.2-ce-ga4/liferay-portal-6.2-ce-ga4 lr62_db_name=lr_migration #LR 7.1 lr71_path=/home/vitaliy/Work/Liferay/migration/liferay-ce-7.1.0-ga1 lr71_archive=liferay-ce-portal-tomcat-7.1.0-ga1-20180703012531655.zip lr71_dir=liferay-ce-portal-7.1.0-ga1 lr71_db_name=lr_migration_dxp
and run the script
./migrate.sh
After finishing script database and data should be already migrated. You can start your Liferay 7.1 instance and check the results.
In my case here they are:
Although there is still no custom theme, layout, hook changes - all the data (pages, content, etc.) is in place, and we can start with code migration.
Create new Liferay project, using Liferay Maven Plugin:
The following structure should appear:
Configure Liferay server in IDE:
yo liferay-theme:import
For hook migration (especially for JSP hooks) it's better to create hook module from scratch, and overwrite the required JSP page. As Liferay's JSP pages have changed significantly from Liferay 6.x to 7.x, using old 6.2 JSP pages for new 7.1 Liferay may break some functionality.
So, you need to create a hook module, find appropriate JSP, and overwrite it in hook, copying changes from 6.2.
To find what exactly was changed in hook, you can compare 2 JSP files in your Liferay 6.2 instance - xxx.jsp (hooked one) and xxx.portal.jsp (original one). In my example:
Then just apply these changes to your Liferay 7.1 page and deploy the hook.
After migration to 7.1 make sure, indexer is enabled. Modify file
Also you need to setup a standalone Elasticsearch instance. Default embedded one can be used for local development, bit not for production. See instructions here:
https://dev.liferay.com/en/discover/deployment/-/knowledge_base/7-1/installing-elasticsearch
Here is a list of errors, which may occur during migration to 7.1
ERROR [main][MainServlet:273] java.lang.RuntimeException: You must first upgrade to Liferay Portal 7100 at com.liferay.portal.tools.DBUpgrader.checkRequiredBuildNumber(DBUpgrader.java:87)
com.liferay.portal.kernel.upgrade.UpgradeException: java.lang.NullPointerException at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:97) at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:134) ... Caused by: java.lang.NullPointerException at com.liferay.dynamic.data.mapping.internal.upgrade.v1_1_2.UpgradeDynamicDataMapping$SelectDDMFormFieldValueTransformer.transform(UpgradeDynamicDataMapping.java:356) at com.liferay.dynamic.data.mapping.util.DDMFormValuesTransformer.performTransformation(DDMFormValuesTransformer.java:58) at com.liferay.dynamic.data.mapping.util.DDMFormValuesTransformer.traverse(DDMFormValuesTransformer.java:78) ...
https://issues.liferay.com/browse/LPS-73485 , https://issues.liferay.com/browse/LPS-69800 , https://issues.liferay.com/browse/LPS-69921
If issue still exists after migration - you can prevent the NPE, if you start Liferay from IDEA in debug mode, then run upgrade process from Felix Gogo Shell, and change the value in evaluator:
com.liferay.portal.kernel.events.ActionException: java.lang.NullPointerException at com.liferay.portal.events.ThemeServicePreAction.run(ThemeServicePreAction.java:46) at com.liferay.portal.kernel.events.Action.processLifecycleEvent(Action.java:34) at java.lang.Thread.run(Thread.java:748) ... Caused by: java.lang.NullPointerException at com.liferay.portal.model.impl.LayoutImpl.getColorScheme(LayoutImpl.java:358) at com.liferay.portal.events.ThemeServicePreAction.servicePre(ThemeServicePreAction.java:72) at com.liferay.portal.events.ThemeServicePreAction.run(ThemeServicePreAction.java:43) ... 113 more
4. PwdEncryptorException: invalid keyLength value
com.liferay.portal.kernel.exception.PwdEncryptorException: invalid keyLength value com.liferay.portal.kernel.exception.PwdEncryptorException: invalid keyLength value at com.liferay.portal.security.pwd.PBKDF2PasswordEncryptor.encrypt(PBKDF2PasswordEncryptor.java:90) at com.liferay.portal.security.pwd.CompositePasswordEncryptor.encrypt(CompositePasswordEncryptor.java:51) at com.liferay.portal.kernel.security.pwd.PasswordEncryptorUtil.encrypt(PasswordEncryptorUtil.java:74) at com.liferay.portal.security.pwd.PwdAuthenticator.authenticate(PwdAuthenticator.java:44) at com.liferay.portal.service.impl.UserLocalServiceImpl.authenticate(UserLocalServiceImpl.java:5789) at com.liferay.portal.service.impl.UserLocalServiceImpl.authenticateByEmailAddress(UserLocalServiceImpl.java:1255) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Add this property
passwords.encryption.algorithm.legacy=SHA
into portal-setup-wizard.properties file.
See full article at:
https://www.aimprosoft.com/blog/liferay-migration-6-2-to-7-1-comprehensive-guide
Vitaliy