javax.persistence.PersistenceException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

Try downgrading PostgresSQL server to 9.5 or update your PostgresSQL driver to 9.4-1211 with the following command: 9.4.1211

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • GitHub comment 121#244860184
    via GitHub by vwilliam
    ,
  • We have done an upgrade from PuppetDB 3.2.4 to PuppetDB 4.1.2 (using apt.puppetlabs.com packages). While the upgrade basically seems to be fine and it looks like that all PuppetDB-related stuff is working too, we see reoccurring duplicate-key-value-violates-unique-constraint in the puppetdb.log: {code:java} 2016-07-21 07:56:07,017 ERROR [p.p.mq-listener] [bc81b75b-9dad-432d-ae6c-a15d4f3e9305] [store report] Retrying after attempt 11 for somenode.example.com, due to: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "reports_hash_expr_idx" Detail: Key (encode(hash, 'hex'::text))=(66929dd40d99b8addcb9f42e02f51675cd6a2357) already exists. org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "reports_hash_expr_idx" Detail: Key (encode(hash, 'hex'::text))=(66929dd40d99b8addcb9f42e02f51675cd6a2357) already exists. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284) ~[puppetdb.jar:na] at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003) ~[puppetdb.jar:na] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200) ~[puppetdb.jar:na] at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424) ~[puppetdb.jar:na] at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161) ~[puppetdb.jar:na] at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133) ~[puppetdb.jar:na] at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) ~[puppetdb.jar:na] at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) ~[puppetdb.jar:na] at clojure.java.jdbc$db_do_prepared_return_keys$exec_and_return_keys__20693.invoke(jdbc.clj:727) ~[na:na] at clojure.java.jdbc$db_do_prepared_return_keys.invokeStatic(jdbc.clj:742) ~[na:na] at clojure.java.jdbc$db_do_prepared_return_keys.invoke(jdbc.clj:714) ~[na:na] at clojure.java.jdbc$multi_insert_helper$fn__20747.invoke(jdbc.clj:937) ~[na:na] at clojure.core$map$fn__4785.invoke(core.clj:2646) ~[puppetdb.jar:na] at clojure.lang.LazySeq.sval(LazySeq.java:40) ~[puppetdb.jar:na] at clojure.lang.LazySeq.seq(LazySeq.java:49) ~[puppetdb.jar:na] at clojure.lang.RT.seq(RT.java:521) ~[puppetdb.jar:na] at clojure.core$seq__4357.invokeStatic(core.clj:137) ~[puppetdb.jar:na] at clojure.core$dorun.invokeStatic(core.clj:3024) ~[puppetdb.jar:na] at clojure.core$doall.invokeStatic(core.clj:3039) ~[puppetdb.jar:na] at clojure.core$doall.invoke(core.clj:3039) ~[puppetdb.jar:na] at clojure.java.jdbc$multi_insert_helper.invokeStatic(jdbc.clj:936) ~[na:na] at clojure.java.jdbc$multi_insert_helper.invoke(jdbc.clj:931) ~[na:na] at clojure.java.jdbc$insert_helper$fn__20750.invoke(jdbc.clj:947) ~[na:na] at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:620) ~[na:na] at clojure.java.jdbc$db_transaction_STAR_.doInvoke(jdbc.clj:568) ~[na:na] at clojure.lang.RestFn.invoke(RestFn.java:425) ~[puppetdb.jar:na] at clojure.java.jdbc$insert_helper.invokeStatic(jdbc.clj:947) ~[na:na] at clojure.java.jdbc$insert_helper.invoke(jdbc.clj:940) ~[na:na] at clojure.java.jdbc$insert_BANG_.invokeStatic(jdbc.clj:1037) ~[na:na] at clojure.java.jdbc$insert_BANG_.doInvoke(jdbc.clj:1024) ~[na:na] at clojure.lang.RestFn.applyTo(RestFn.java:142) ~[puppetdb.jar:na] at clojure.core$apply.invokeStatic(core.clj:650) ~[puppetdb.jar:na] at clojure.core$apply.invoke(core.clj:641) ~[puppetdb.jar:na] at puppetlabs.puppetdb.jdbc$insert_BANG_.invokeStatic(jdbc.clj:64) ~[na:na] at puppetlabs.puppetdb.jdbc$insert_BANG_.doInvoke(jdbc.clj:57) ~[na:na] at clojure.lang.RestFn.invoke(RestFn.java:423) ~[puppetdb.jar:na] at puppetlabs.puppetdb.scf.storage$eval35201$add_report_BANG__STAR___35206$fn__35207$fn__35208$fn__35210.invoke(storage.clj:1260) ~[na:na] at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:620) ~[na:na] at clojure.java.jdbc$db_transaction_STAR_.doInvoke(jdbc.clj:568) ~[na:na] at clojure.lang.RestFn.invoke(RestFn.java:425) ~[puppetdb.jar:na] at puppetlabs.puppetdb.scf.storage$eval35201$add_report_BANG__STAR___35206$fn__35207$fn__35208.invoke(storage.clj:1236) ~[na:na] at puppetlabs.puppetdb.scf.storage.proxy$java.lang.Object$Callable$7da976d4.call(Unknown Source) ~[na:na] at com.codahale.metrics.Timer.time(Timer.java:101) ~[puppetdb.jar:na] at puppetlabs.puppetdb.scf.storage$eval35201$add_report_BANG__STAR___35206$fn__35207.invoke(storage.clj:1229) ~[na:na] at puppetlabs.puppetdb.scf.storage$eval35201$add_report_BANG__STAR___35206.invoke(storage.clj:1221) ~[na:na] at puppetlabs.puppetdb.scf.storage$eval35437$add_report_BANG___35442$fn__35443.invoke(storage.clj:1400) ~[na:na] at puppetlabs.puppetdb.scf.storage$eval35437$add_report_BANG___35442.invoke(storage.clj:1396) ~[na:na] at puppetlabs.puppetdb.command$store_report_STAR_$fn__40763.invoke(command.clj:331) ~[na:na] at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn$fn__21230$fn__21231.invoke(jdbc.clj:306) ~[na:na] at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:595) ~[na:na] at clojure.java.jdbc$db_transaction_STAR_.doInvoke(jdbc.clj:568) ~[na:na] at clojure.lang.RestFn.invoke(RestFn.java:464) ~[puppetdb.jar:na] at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn$fn__21230.invoke(jdbc.clj:305) ~[na:na] at puppetlabs.puppetdb.jdbc$eval21204$retry_sql_STAR___21209$fn__21210$fn__21211.invoke(jdbc.clj:283) ~[na:na] at puppetlabs.puppetdb.jdbc$eval21204$retry_sql_STAR___21209$fn__21210.invoke(jdbc.clj:282) ~[na:na] at puppetlabs.puppetdb.jdbc$eval21204$retry_sql_STAR___21209.invoke(jdbc.clj:273) ~[na:na] at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn.invokeStatic(jdbc.clj:303) ~[na:na] at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn.invoke(jdbc.clj:298) ~[na:na] at puppetlabs.puppetdb.command$store_report_STAR_.invokeStatic(command.clj:329) ~[na:na] at puppetlabs.puppetdb.command$store_report_STAR_.invoke(command.clj:324) ~[na:na] at puppetlabs.puppetdb.command$store_report.invokeStatic(command.clj:348) ~[na:na] at puppetlabs.puppetdb.command$store_report.invoke(command.clj:336) ~[na:na] at puppetlabs.puppetdb.command$process_command_BANG_.invokeStatic(command.clj:370) ~[na:na] at puppetlabs.puppetdb.command$process_command_BANG_.invoke(command.clj:363) ~[na:na] at puppetlabs.puppetdb.command$process_command_and_respond_BANG_.invokeStatic(command.clj:415) ~[na:na] at puppetlabs.puppetdb.command$process_command_and_respond_BANG_.invoke(command.clj:413) ~[na:na] at puppetlabs.puppetdb.command$reify__40907$service_fnk__11356__auto___positional$reify__40918$fn__40921.invoke(command.clj:451) ~[na:na] at puppetlabs.puppetdb.mq_listener$reify__41157$service_fnk__11356__auto___positional$reify__41167.process_message(mq_listener.clj:412) ~[na:na] at puppetlabs.puppetdb.mq_listener$reify__41157$service_fnk__11356__auto___positional$reify__41167$process_msg__41168.invoke(mq_listener.clj:380) ~[na:na] at puppetlabs.puppetdb.mq_listener$wrap_with_discard$fn__40983$fn__40985.invoke(mq_listener.clj:228) ~[na:na] at puppetlabs.puppetdb.mq_listener.proxy$java.lang.Object$Callable$7da976d4.call(Unknown Source) ~[na:na] at com.codahale.metrics.Timer.time(Timer.java:101) ~[puppetdb.jar:na] at puppetlabs.puppetdb.mq_listener$wrap_with_discard$fn__40983.invoke(mq_listener.clj:227) ~[na:na] at puppetlabs.puppetdb.mq_listener$wrap_with_exception_handling$fn__40971$fn__40973.invoke(mq_listener.clj:182) ~[na:na] at puppetlabs.puppetdb.mq_listener.proxy$java.lang.Object$Callable$7da976d4.call(Unknown Source) ~[na:na] at com.codahale.metrics.Timer.time(Timer.java:101) ~[puppetdb.jar:na] at puppetlabs.puppetdb.mq_listener$wrap_with_exception_handling$fn__40971.invoke(mq_listener.clj:181) ~[na:na] at puppetlabs.puppetdb.mq_listener$wrap_with_command_parser$fn__40979.invoke(mq_listener.clj:204) [na:na] at puppetlabs.puppetdb.mq_listener$wrap_with_meter$fn__40963.invoke(mq_listener.clj:142) [na:na] at puppetlabs.puppetdb.mq_listener$wrap_with_thread_name$fn__40990.invoke(mq_listener.clj:243) [na:na] at puppetlabs.puppetdb.mq_listener$start_receiver$reify__41150.onMessage(mq_listener.clj:360) [na:na] at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1401) [puppetdb.jar:na] at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131) [puppetdb.jar:na] at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202) [puppetdb.jar:na] at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133) [puppetdb.jar:na] at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) [puppetdb.jar:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_101] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_101] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_101] {code} Despite this message, reports seems to be stored fine in PuppetDB - at least what we can see with puppetboard. I'm not sure if this is related, but also another message is displayed since the ugprade to 4.1.2 and appears ahead the "store report" entries: {code:java} 2016-07-21 07:56:07,495 WARN [p.p.h.command] Unable to stream command posted without parameters (loading into RAM) 2016-07-21 07:56:07,527 INFO [p.p.command] [6bd95e5b-7d5c-45c2-a238-65f1812f7a3a] [store report] puppet v3.8.5 - somenode1.example.com 2016-07-21 07:56:07,880 WARN [p.p.h.command] Unable to stream command posted without parameters (loading into RAM) 2016-07-21 07:56:07,912 INFO [p.p.command] [f839e90d-6ece-44e2-9abf-1fdb4eeb7e89] [store report] puppet v3.8.5 - somenode2.example.com {code}
    via by Andreas Unterkircher,
  • GitHub comment 9317#246692261
    via GitHub by kosii
    ,
  • Add section for PREPARE
    via GitHub by begriffs
    ,
  • Hibernate and PostgreSQL Sequences
    via Stack Overflow by mah454
    ,
    • javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1402) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:472) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3132) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2369) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:147) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:221) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68) at org.friends.app.dao.impl.UserDaoImpl.delete(UserDaoImpl.java:77) at org.friends.app.dao.impl.UserDaoImpl$$FastClassBySpringCGLIB$$74eef025.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) at org.friends.app.dao.impl.UserDaoImpl$$EnhancerBySpringCGLIB$$50b9eb90.delete(<generated>) at org.friends.app.service.impl.UserServiceBean.delete(UserServiceBean.java:239) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy29.delete(Unknown Source) at org.friends.app.view.route.UnregisterRoute.doHandle(UnregisterRoute.java:29) at org.friends.app.view.route.AuthenticatedRoute.handle(AuthenticatedRoute.java:26) at spark.TemplateViewRouteImpl$1.handle(TemplateViewRouteImpl.java:66) at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:162) at spark.servlet.SparkFilter.doFilter(SparkFilter.java:122) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:827) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207) at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3246) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3483) at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:99) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1396) ... 58 more Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "users" violates foreign key constraint "fkey_user_id" on table "sessions" Detail: Key (id)=(1) is still referenced from table "sessions". at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161) at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:133) at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:97) at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:97) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204) ... 67 more

    Users with the same issue

    serious2monkeys
    4 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    derprogger
    1 times, last one,
    Unknown User
    7 times, last one,
    91 more bugmates