Stian,
What you explained seem to contradict the documented purpose for the
IGNORE_EXISTING import option.
/Hristo Stoyanov
On Feb 1, 2016 2:35 AM, "Stian Thorgersen" <sthorger(a)redhat.com> wrote:
The import is really meant for a clean database. Or at least to
import
non-existing realms.
Why are you doing an import during upgrade if you are not starting with a
clean database?
On 1 February 2016 at 08:55, Marek Posolda <mposolda(a)redhat.com> wrote:
> Hi,
>
> could you please create JIRA? Until it's fixed, I suggest to backup your
> DB and instead use strategy OVERWRITE_EXISTING (or just remove strategy
> property as OVERWRITE_EXISTING is the default)
>
> Marek
>
>
> On 01/02/16 07:47, Hristo Stoyanov wrote:
>
> Hi all,
> I ma trying to install KC1.8.Final over a previous KC1.7 installation
> backed by Postgres. I use template files to bootstrap my realm:
>
> 36 -rw-r--r-- 1 root root 36806 Feb 1 05:50 FinancialApps-realm.json
> 40 -rw-r--r-- 1 root root 39545 Feb 1 05:50 master-realm.json
> 4 -rw-r--r-- 1 root root 709 Feb 1 05:50 master-users-0.json
> 4 -rw-r--r-- 1 root root 77 Feb 1 05:50 version.json
>
> and I use the import facility:
>
> -Dkeycloak.migration.action=import \
> -Dkeycloak.migration.provider=dir \
> -Dkeycloak.migration.dir={{wildfly_home}}/keycloak \
> -Dkeycloak.migration.strategy=IGNORE_EXISTING
>
> Below is the exception I get. I understand that I can wipe out my
> Postgress database and have a clean import, but I thought the import was
> careful enough to check for duplicate keys???
> =================================================================
> Caused by: org.keycloak.models.ModelDuplicateException:
> javax.persistence.PersistenceException:
> org.hibernate.exception.ConstraintViolationException: could not execute
> statement
> at
>
org.keycloak.connections.jpa.PersistenceExceptionConverter.convert(PersistenceExceptionConverter.java:40)
> at
>
org.keycloak.connections.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:34)
> at com.sun.proxy.$Proxy83.flush(Unknown Source)
> at
> org.keycloak.models.jpa.JpaUserProvider.addUser(JpaUserProvider.java:61)
> at
>
org.keycloak.models.cache.infinispan.DefaultCacheUserProvider.addUser(DefaultCacheUserProvider.java:267)
> at
>
org.keycloak.models.utils.RepresentationToModel.createUser(RepresentationToModel.java:1168)
> at
> org.keycloak.exportimport.util.ImportUtils.importUsers(ImportUtils.java:191)
> at
>
org.keycloak.exportimport.util.ImportUtils.importUsersFromStream(ImportUtils.java:175)
> at
>
org.keycloak.exportimport.dir.DirImportProvider$4.runExportImportTask(DirImportProvider.java:121)
> at
>
org.keycloak.exportimport.util.ExportImportSessionTask.run(ExportImportSessionTask.java:18)
> at
>
org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:267)
> at
>
org.keycloak.exportimport.dir.DirImportProvider.importRealm(DirImportProvider.java:117)
> at
>
org.keycloak.exportimport.dir.DirImportProvider.importModel(DirImportProvider.java:55)
> at
> org.keycloak.exportimport.ExportImportManager.runImport(ExportImportManager.java:69)
> at
>
org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:107)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
>
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> at
>
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
> at
>
org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:150)
> ... 19 more
> Caused by: javax.persistence.PersistenceException:
> org.hibernate.exception.ConstraintViolationException: could not execute
> statement
> at
>
org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
> at
>
org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
> at
>
org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1608)
> at
>
org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1303)
> at sun.reflect.GeneratedMethodAccessor300.invoke(Unknown Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:497)
> at
>
org.keycloak.connections.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:32)
> ... 37 more
> 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:109)
> at
> org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
> 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.insert(AbstractEntityPersister.java:2886)
> at
>
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3386)
> at
> org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
> 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:1282)
> at
>
org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1300)
> ... 41 more
> *Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value
> violates unique constraint "uk_ru8tt6t700s9v50bu18ws5ha6"*
> * Detail: Key (realm_id, username)=(master, admin) already exists.*
> at
>
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2182)
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1911)
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:173)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:645)
> at
>
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:495)
> at
>
org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:441)
> at sun.reflect.GeneratedMethodAccessor295.invoke(Unknown Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:497)
> at
>
org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection$StatementHandler.invoke(AbstractJdbc23PooledConnection.java:453)
> at com.sun.proxy.$Proxy84.executeUpdate(Unknown Source)
> at
>
org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:537)
> at
>
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)
>
>
>
> _______________________________________________
> keycloak-user mailing
listkeycloak-user@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/keycloak-user
>
>
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/keycloak-user
>