掲示板

Database upgrade to 7.0 fails with a NullPointerException

7年前 に Thomas Kellerer によって更新されました。

Database upgrade to 7.0 fails with a NullPointerException

Expert 投稿: 490 参加年月日: 08/06/09 最新の投稿
When I try to upgrade my database to 7.0 (after doing an upgrade from 6.0 to 6.1, then from 6.1 to 6.2) it fails with a NullPointerException:
14:13:40,130 INFO  [main][UpgradeProcess:97] Completed upgrade process com.liferay.portal.upgrade.UpgradeProcess_7_0_1 in 202ms
com.liferay.portal.kernel.upgrade.UpgradeException: com.liferay.portal.kernel.upgrade.UpgradeException: java.lang.NullPointerException
        at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:91)
        at com.liferay.portal.kernel.upgrade.util.UpgradeProcessUtil._upgradeProcess(UpgradeProcessUtil.java:175)
        at com.liferay.portal.kernel.upgrade.util.UpgradeProcessUtil.upgradeProcess(UpgradeProcessUtil.java:143)
        at com.liferay.portal.kernel.upgrade.util.UpgradeProcessUtil.upgradeProcess(UpgradeProcessUtil.java:125)
        at com.liferay.portal.events.StartupHelper.upgradeProcess(StartupHelper.java:164)
        at com.liferay.portal.events.StartupHelperUtil.upgradeProcess(StartupHelperUtil.java:81)
        at com.liferay.portal.tools.DBUpgrader.upgrade(DBUpgrader.java:157)
        at com.liferay.portal.tools.DBUpgrader.main(DBUpgrader.java:103)
Caused by: com.liferay.portal.kernel.upgrade.UpgradeException: java.lang.NullPointerException
        at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:91)
        at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:115)
        at com.liferay.portal.upgrade.UpgradeProcess_7_0_1.doUpgrade(UpgradeProcess_7_0_1.java:41)
        at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:88)
        ... 7 more
Caused by: java.lang.NullPointerException
        at com.liferay.util.Encryptor.serializeKey(Encryptor.java:256)
        at com.liferay.portal.upgrade.v7_0_1.UpgradeCompany.updateCompanyKey(UpgradeCompany.java:49)
        at com.liferay.portal.upgrade.v7_0_1.UpgradeCompany.doUpgrade(UpgradeCompany.java:34)
        at com.liferay.portal.kernel.upgrade.UpgradeProcess.upgrade(UpgradeProcess.java:88)
        ... 10 more

Any idea how to fix this?

I can see that this fails because the column key_ in the table company is null - but I have no idea what the correct value for that should be.
thumbnail
7年前 に Jorge Díaz によって更新されました。

RE: Database upgrade to 7.0 fails with a NullPointerException

Liferay Master 投稿: 753 参加年月日: 14/01/09 最新の投稿
Hi Thomas,

You can regenerate company.key field calling one following method:
com.liferay.portal.service.CompanyLocalServiceUtil.checkCompanyKey(long companyId)
from Control Panel => Server Administration => Script and select "groovy"
More info about that method, see: https://github.com/liferay/liferay-portal/blob/6.2/portal-impl/src/com/liferay/portal/service/impl/CompanyLocalServiceImpl.java#L473
7年前 に Thomas Kellerer によって更新されました。

RE: Database upgrade to 7.0 fails with a NullPointerException

Expert 投稿: 490 参加年月日: 08/06/09 最新の投稿
Thanks for the answer. I was hoping I could do the whole 6.0 to 7.0 migration without the need to start any of the intermediate Liferay versions.

It turns out that the upgrade process finishes "successfully" if I simply copy the original key from the 6.0 database.

However, now there are several Postgres specific errors in the logfile:
08:54:48,465 WARN  [main][UpgradeProcess:350] Fallback to recreating the table
org.postgresql.util.PSQLException: ERROR: cannot drop index listtype_pkey because constraint listtype_pkey on table listtype requires it_  Hint: You can drop constraint listtype_pkey on table listtype instead. [Sanitized]
and
org.postgresql.util.PSQLException: ERROR: cannot drop index layoutbranch_pkey because constraint layoutbranch_pkey on table layoutbranch requires it_  Hint: You can drop constraint layoutbranch_pkey on table layoutbranch instead. [Sanitized]

I can workaround those two errors above by dropping the primary key constraint manually before starting the upgrade. However if I do that for the table layoutbranch, the following error shows up in the logfile:
09:18:04,930 WARN  [main][UpgradeProcess:350] Fallback to recreating the table
org.postgresql.util.PSQLException: ERROR: column "layoutbranchid" of relation "layoutbranch" already exists
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2412)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2125)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:297)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:301)
	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:287)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:264)
	at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:244)
	at com.liferay.portal.dao.db.BaseDB.runSQL(BaseDB.java:291)
	at com.liferay.portal.dao.db.BaseDB.runSQL(BaseDB.java:261)
	at com.liferay.portal.kernel.dao.db.BaseDBProcess.runSQL(BaseDBProcess.java:52)
	at com.liferay.portal.kernel.upgrade.UpgradeProcess.alter(UpgradeProcess.java:320)
	at com.liferay.portal.upgrade.v7_0_1.UpgradeLayoutBranch.doUpgrade(UpgradeLayoutBranch.java:27)
Not sure if that is a problem or not.

I am also affected by the sloppy data type usage from bug https://issues.liferay.com/browse/LPS-68582
But as that method only updates the expiration date of the article, it probably isn't a big deal.
7年前 に Thomas Kellerer によって更新されました。

RE: Database upgrade to 7.0 fails with a NullPointerException

Expert 投稿: 490 参加年月日: 08/06/09 最新の投稿
Liferay 7 does start up despite the errors, but none of the users are visible in the control panel (but I can log in with the existing users)

I re-indexed everything from the control panel, but the users still don't show up in the control panel.

Any ideas?
thumbnail
7年前 に Jorge Díaz によって更新されました。

RE: Database upgrade to 7.0 fails with a NullPointerException

Liferay Master 投稿: 753 参加年月日: 14/01/09 最新の投稿
Try activating DEBUG traces for search log categories in order to verify the queries executed to elasticsearch.

You can also try deactivating index search and do users queries to database (slower)
You can use database with following property:
users.search.with.index=false
7年前 に Thomas Kellerer によって更新されました。

RE: Database upgrade to 7.0 fails with a NullPointerException

Expert 投稿: 490 参加年月日: 08/06/09 最新の投稿
Jorge Díaz:
users.search.with.index=false

Thanks, that indeed worked.

But I finally found why the index wasn't created:

In the documentation of the upgrade procedure (https://dev.liferay.com/discover/deployment/-/knowledge_base/7-0/upgrading-to-liferay-7#disable-indexing-during-the-upgrade-process) it is recommended to set the index to read only and I simply forgot to remove that configuration after the upgrade.

So it was the typical case of PEBKAC ;) Sorry for the noise.

But there are some more problems with the migrated instance:

The display (theme) of the control panel seems to be broken and I can't figure out how to reset it. For example the dropdown menu in the upper right corner of each portlet in the control panel (where the three vertical dots are located) isn't available in the migrated environment. It only says "Control Panel" there and when you hover the mouse over it something shows up and then vanishes immediately - too fast to be able to see what that should be. The lower part of the portlet area in the control panel also seems to be messed up somehow (see attached file users-portlet.png). I do see a lot of " No theme found for specified theme id classic. Returning the default theme." messages in the console - but I don't know how to make Liferay look for the correct theme.

I would like to get this to a point where I can reliably export users, roles, permissions and organizations into a LAR so that I can import them in an empty Liferay 7 installation (but as long as I can't even see the users that are present in the database and the export option is not accessible this is not possible).

添付ファイル: