[keycloak-user] Exported realm cannot be imported

Christina Lau christinalau28 at icloud.com
Wed Aug 20 20:45:17 EDT 2014


I tried again from command line and got exactly the same error.
./standalone.sh -Dkeycloak.migration.action=import -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=dsgapi.json -Dkeycloak.migration.strategy=OVERWRITE_EXISTING

20:40:09,393 INFO  [org.keycloak.exportimport.util.ImportUtils] (MSC service thread 1-15) Realm 'DSG_API' already exists. Removing it before import
20:40:09,558 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (MSC service thread 1-15) SQL Error: 23505, SQLState: 23505
20:40:09,559 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (MSC service thread 1-15) Unique index or primary key violation: "UK_ORVSDMLA56612EAEFIQ6WL5OI_INDEX_4 ON PUBLIC.REALM(NAME) VALUES ( /* 73 */ 'DSG_API' )"; SQL statement:
insert into REALM (ACCESS_CODE_LIFESPAN, USER_ACTION_LIFESPAN, ACCESS_TOKEN_LIFESPAN, ACCOUNT_THEME, ADMIN_THEME, AUDIT_ENABLED, AUDIT_EXPIRATION, BRUTE_FORCE_PROTECTED, EMAIL_THEME, ENABLED, FAILURE_FACTOR, LOGIN_THEME, MASTER_ADMIN_APP, MAX_DELTA_TIME, MAX_FAILURE_WAIT, MINIMUM_QUICK_LOGIN_WAIT, NAME, NOT_BEFORE, PASSWORD_CRED_GRANT_ALLOWED, PASSWORD_POLICY, PRIVATE_KEY, PUBLIC_KEY, QUICK_LOGIN_CHECK, REGISTRATION_ALLOWED, REMEMBER_ME, RESET_PASSWORD_ALLOWED, SOCIAL, SSL_REQUIRED, SSO_IDLE_TIMEOUT, SSO_MAX_LIFESPAN, UPDATE_PROFILE_ON_SOC_LOGIN, VERIFY_EMAIL, WAIT_INCREMENT_SECONDS, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23505-173]
20:40:09,560 INFO  [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (MSC service thread 1-15) HHH000010: On release of batch it still contained JDBC statements
20:40:09,569 ERROR [org.keycloak.exportimport.ExportImportManager] (MSC service thread 1-15) Error during export/import: 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) [keycloak-connections-jpa-1.0-beta-4.jar:]
	at org.keycloak.connections.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:34) [keycloak-connections-jpa-1.0-beta-4.jar:]
	at com.sun.proxy.$Proxy88.flush(Unknown Source)
	at org.keycloak.models.jpa.JpaRealmProvider.createRealm(JpaRealmProvider.java:45) [keycloak-model-jpa-1.0-beta-4.jar:]
	at org.keycloak.models.cache.DefaultCacheRealmProvider.createRealm(DefaultCacheRealmProvider.java:161) [keycloak-invalidation-cache-model-1.0-beta-4.jar:]
	at org.keycloak.exportimport.util.ImportUtils.importRealm(ImportUtils.java:64) [keycloak-export-import-api-1.0-beta-4.jar:]
	at org.keycloak.exportimport.util.ImportUtils.importFromStream(ImportUtils.java:165) [keycloak-export-import-api-1.0-beta-4.jar:]
	at org.keycloak.exportimport.singlefile.SingleFileImportProvider$1.run(SingleFileImportProvider.java:43) [keycloak-export-import-single-file-1.0-beta-4.jar:]
	at org.keycloak.exportimport.util.ExportImportUtils.runJobInTransaction(ExportImportUtils.java:27) [keycloak-export-import-api-1.0-beta-4.jar:]
	at org.keycloak.exportimport.singlefile.SingleFileImportProvider.importModel(SingleFileImportProvider.java:38) [keycloak-export-import-single-file-1.0-beta-4.jar:]
	at org.keycloak.exportimport.ExportImportManager.checkExportImport(ExportImportManager.java:49) [keycloak-export-import-api-1.0-beta-4.jar:]
	at org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:82) [keycloak-services-1.0-beta-4.jar:]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_55]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_55]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_55]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [rt.jar:1.7.0_55]
	at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:148) [resteasy-jaxrs-3.0.8.Final.jar:]
	at org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2175) [resteasy-jaxrs-3.0.8.Final.jar:]
	at org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:295) [resteasy-jaxrs-3.0.8.Final.jar:]
	at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:236) [resteasy-jaxrs-3.0.8.Final.jar:]
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:112) [resteasy-jaxrs-3.0.8.Final.jar:]
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-3.0.8.Final.jar:]
	at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:214) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
	at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:119) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
	at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:505) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55]
	at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_55]
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1338) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
	at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source) [:1.7.0_55]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_55]
	at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_55]
	at org.keycloak.connections.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:32) [keycloak-connections-jpa-1.0-beta-4.jar:]
	... 30 more
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
	at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:129) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:190) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:62) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3124) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3581) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:104) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:349) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1335) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
	... 34 more
Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "UK_ORVSDMLA56612EAEFIQ6WL5OI_INDEX_4 ON PUBLIC.REALM(NAME) VALUES ( /* 73 */ 'DSG_API' )"; SQL statement:
insert into REALM (ACCESS_CODE_LIFESPAN, USER_ACTION_LIFESPAN, ACCESS_TOKEN_LIFESPAN, ACCOUNT_THEME, ADMIN_THEME, AUDIT_ENABLED, AUDIT_EXPIRATION, BRUTE_FORCE_PROTECTED, EMAIL_THEME, ENABLED, FAILURE_FACTOR, LOGIN_THEME, MASTER_ADMIN_APP, MAX_DELTA_TIME, MAX_FAILURE_WAIT, MINIMUM_QUICK_LOGIN_WAIT, NAME, NOT_BEFORE, PASSWORD_CRED_GRANT_ALLOWED, PASSWORD_POLICY, PRIVATE_KEY, PUBLIC_KEY, QUICK_LOGIN_CHECK, REGISTRATION_ALLOWED, REMEMBER_ME, RESET_PASSWORD_ALLOWED, SOCIAL, SSL_REQUIRED, SSO_IDLE_TIMEOUT, SSO_MAX_LIFESPAN, UPDATE_PROFILE_ON_SOC_LOGIN, VERIFY_EMAIL, WAIT_INCREMENT_SECONDS, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23505-173]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
	at org.h2.message.DbException.get(DbException.java:171)
	at org.h2.message.DbException.get(DbException.java:148)
	at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:101)
	at org.h2.index.PageBtree.find(PageBtree.java:121)
	at org.h2.index.PageBtreeLeaf.addRow(PageBtreeLeaf.java:148)
	at org.h2.index.PageBtreeLeaf.addRowTry(PageBtreeLeaf.java:101)
	at org.h2.index.PageBtreeIndex.addRow(PageBtreeIndex.java:95)
	at org.h2.index.PageBtreeIndex.add(PageBtreeIndex.java:86)
	at org.h2.table.RegularTable.addRow(RegularTable.java:125)
	at org.h2.command.dml.Insert.insertRows(Insert.java:127)
	at org.h2.command.dml.Insert.update(Insert.java:86)
	at org.h2.command.CommandContainer.update(CommandContainer.java:79)
	at org.h2.command.Command.executeUpdate(Command.java:235)
	at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:154)
	at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:140)
	at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)
	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:187) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
	... 44 more

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20140820/3247758c/attachment-0001.html 


More information about the keycloak-user mailing list