[JAVA][Liferay] Duplicate key value violates unique constraint for resourcepermissionid in Liferay(代

Posted 种花生的读书人

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[JAVA][Liferay] Duplicate key value violates unique constraint for resourcepermissionid in Liferay(代相关的知识,希望对你有一定的参考价值。

Unexpected exception thrown when create new site:

09:47:10,114 ERROR [ajp-bio-8009-exec-113][JDBCExceptionReporter:82] Batch entry 0 insert into ResourcePermission (companyId, name, scope, primKey, roleId, ownerId, actionIds, resourcePermissionId) values ('10157', 'com.liferay.portlet.documentlibrary.model.DLFileEntry', '4', '24728', '10173', '0', '3', '11366') was aborted.  Call getNextException to see the cause.
09:47:10,115 ERROR [ajp-bio-8009-exec-113][JDBCExceptionReporter:82] ERROR: duplicate key value violates unique constraint "resourcepermission_pkey"_  Detail: Key (resourcepermissionid)=(11366) already exists. [Sanitized]

Solution:

The doubling was caused by the Counter service (not sure what it actually does but assume it generates unique ids for primary keys).

These changes are in the tomcat\webapps\ROOT\WEB-INF\classes\portal-ext.properties file

##
## Counter
##

#
# The counter operates with is own data source to prevent deadlocks. By
# default, the data source created for the counter uses the same settings as
# those used to create the data source used for the rest of the portal. That
# happens by because the counter service will look up the properties
# prefixed with "jdbc.default." to create its data source. See the JDBC
# properties prefixed with "jdbc.default." for more information.
#
# Setting a different value for the counter JDBC prefix allows you to better
# fine tune the counter data source with its own set of configuration
# settings for high availability installations. Note that these settings,
# though separate, are a copy of the default settings with the newly
# overridden values.
#
counter.jdbc.prefix=jdbc.counter.
jdbc.counter.maxPoolSize=3
jdbc.counter.minPoolSize=1
jdbc.counter.numHelperThreads=1

#
# Set the number of increments between database updates to the Counter
# table. Set this value to a higher number for better performance.
#
counter.increment=100

以上是关于[JAVA][Liferay] Duplicate key value violates unique constraint for resourcepermissionid in Liferay(代的主要内容,如果未能解决你的问题,请参考以下文章

java Liferay资源返回json

java Spring Interceptor隐藏Liferay错误消息

如何在Liferay Custom JSP Fragment项目中加Java代码

在 liferay javascript 不工作(用户操作没有触发)[重复]

Liferay 6.0 使用 java 控制器从 db 获取 WebForm-portlet 数据

liferay6关于liferay中使用requestMapping映射地址提交表单