[keycloak-user] Exporting a realm
Stian Thorgersen
stian at redhat.com
Thu May 22 10:03:49 EDT 2014
Are you using master? It should be recently fixed as it used to do the import after creating the default domain
----- Original Message -----
> From: "Stan Silvert" <ssilvert at redhat.com>
> To: "Stian Thorgersen" <stian at redhat.com>
> Cc: keycloak-user at lists.jboss.org
> Sent: Thursday, 22 May, 2014 2:54:12 PM
> Subject: Re: [keycloak-user] Exporting a realm
>
> The import didn't work. I've attached my json files. Here is the error:
>
> 09:43:06,054 INFO [org.keycloak.exportimport.ExportImportProviderImpl]
> (MSC service thread 1-5) Full model import requested
> 09:43:06,055 INFO [org.keycloak.exportimport.ExportImportProviderImpl]
> (MSC service thread 1-5) Requested migration provider: dir
> 09:43:06,058 INFO
> [org.keycloak.exportimport.io.directory.TmpDirImportReader] (MSC service
> thread 1-5) Importing from directory C:\GitHub\wildfly\keycloak\import
> 09:43:06,161 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper]
> (MSC service thread 1-5) SQL Error: 23503, SQLState: 23503
> 09:43:06,162 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper]
> (MSC service thread 1-5) Referential integrity constraint violation:
> "FK_I5JDI3H6YCO42LDGL3XAXN3G8:
> PUBLIC.REALMENTITY FOREIGN KEY(MASTERADMINAPP_ID) REFERENCES
> PUBLIC.CLIENTENTITY(ID) ('5f07ac64-2e74-413b-bf38-e3108d5a9317')"; SQL
> statement:
> delete from ClientEntity where id=? [23503-173]
> 09:43:06,168 INFO
> [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (MSC
> service thread 1-5) HHH000010: On release of batch it still contained
> JDBC statements
>
> 09:43:06,173 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5)
> MSC000001: Failed to start service
> jboss.undertow.deployment.default-server.default-host./auth: o
> rg.jboss.msc.service.StartException in service
> jboss.undertow.deployment.default-server.default-host./auth: Failed to
> start service
> at
> org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
> [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
> Source) [rt.jar:1.7.0_51]
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source) [rt.jar:1.7.0_51]
> at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_51]
> Caused by: java.lang.RuntimeException: Failed to construct public
> org.keycloak.services.resources.KeycloakApplication(javax.servlet.ServletContext,org.jboss.resteasy.core
> .Dispatcher)
> at
> org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:160)
> at
> org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2175)
> at
> org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:295)
> at
> org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:236)
> at
> org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:112)
> at
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
> at
> io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:214)
> at
> io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:119)
> at
> io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:501)
> at
> org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
> at
> org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:71)
> at
> org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
> [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
> at
> org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
> [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
> ... 3 more
> Caused by: java.lang.RuntimeException:
> org.keycloak.models.ModelDuplicateException:
> javax.persistence.PersistenceException:
> org.hibernate.exception.ConstraintViolationExc
> eption: could not execute statement
> at
> org.keycloak.exportimport.ExportImportProviderImpl.checkExportImport(ExportImportProviderImpl.java:65)
> at
> org.keycloak.services.resources.KeycloakApplication.checkExportImportProvider(KeycloakApplication.java:233)
> at
> org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:92)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> [rt.jar:1.7.0_51]
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
> [rt.jar:1.7.0_51]
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
> Source) [rt.jar:1.7.0_51]
> at java.lang.reflect.Constructor.newInstance(Unknown Source)
> [rt.jar:1.7.0_51]
> at
> org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:148)
> ... 15 more
> Caused by: org.keycloak.models.ModelDuplicateException:
> javax.persistence.PersistenceException:
> org.hibernate.exception.ConstraintViolationException: could not execute st
> atement
> at
> org.keycloak.models.jpa.PersistenceExceptionConverter.convert(PersistenceExceptionConverter.java:41)
> at
> org.keycloak.models.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:35)
> at com.sun.proxy.$Proxy108.flush(Unknown Source)
> at
> org.keycloak.models.jpa.ApplicationAdapter.removeRole(ApplicationAdapter.java:137)
> at
> org.keycloak.models.jpa.RealmAdapter.removeApplication(RealmAdapter.java:643)
> at
> org.keycloak.models.jpa.JpaKeycloakSession.removeRealm(JpaKeycloakSession.java:85)
> at
> org.keycloak.models.jpa.JpaKeycloakSession.removeAllData(JpaKeycloakSession.java:112)
> at
> org.keycloak.exportimport.ModelImporter.importModel(ModelImporter.java:56)
> at
> org.keycloak.exportimport.ExportImportProviderImpl.checkExportImport(ExportImportProviderImpl.java:50)
> ... 22 more
> Caused by: javax.persistence.PersistenceException:
> org.hibernate.exception.ConstraintViolationException: could not execute
> statement
> at
> org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763)
> at
> org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
> at
> org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683)
> at
> org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1338)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [rt.jar:1.7.0_51]
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> [rt.jar:1.7.0_51]
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source) [rt.jar:1.7.0_51]
> at java.lang.reflect.Method.invoke(Unknown Source)
> [rt.jar:1.7.0_51]
> at
> org.keycloak.models.jpa.PersistenceExceptionConverter.invoke(PersistenceExceptionConverter.java:33)
> ... 29 more
> Caused by: org.hibernate.exception.ConstraintViolationException: could
> not execute statement
> at
> org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:129)
> at
> org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
> at
> org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
> at
> org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
> at
> org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:190)
> at
> org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:62)
> at
> org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3400)
> at
> org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3630)
> at
> org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:114)
> at
> org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
> at
> org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:349)
> at
> org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
> at
> org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
> at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222)
> at
> org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1335)
> ... 34 more
> Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity
> constraint violation: "FK_I5JDI3H6YCO42LDGL3XAXN3G8: PUBLIC.REALMENTITY
> FOREIGN KEY(MASTERADMINAPP_ID) REFE
> RENCES PUBLIC.CLIENTENTITY(ID)
> ('5f07ac64-2e74-413b-bf38-e3108d5a9317')"; SQL statement:
> delete from ClientEntity where id=? [23503-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.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:421)
> at
> org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:438)
> at
> org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:314)
> at org.h2.table.Table.fireConstraints(Table.java:880)
> at org.h2.table.Table.fireAfterRow(Table.java:897)
> at org.h2.command.dml.Delete.update(Delete.java:100)
> 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)
> ... 44 more
>
>
> On 5/22/2014 3:59 AM, Stian Thorgersen wrote:
> > To make sure that no changes are made while exporting, currently this is
> > done at startup. It's initiated by setting some system properties:
> >
> > For unencrypted export:
> >
> > # bin/standalone.sh -Dkeycloak.migration.action=export
> > -Dkeycloak.migration.provider=dir -Dkeycloak.migration.dir=<DIR TO
> > EXPORT TO>
> >
> > or for an encrypted export:
> >
> > # bin/standalone.sh -Dkeycloak.migration.action=export
> > -Dkeycloak.migration.provider=zip -Dkeycloak.migration.zipFile=<FILE TO
> > EXPORT TO> -Dkeycloak.migration.zipPassword=<PASSWORD TO DECRYPT EXPORT>
> >
> > You can then re-import it by replacing -Dkeycloak.migration.action=export
> > with -Dkeycloak.migration.action=import
> >
> > It'll be made easier in the future ;)
> >
> > ----- Original Message -----
> >> From: "Stan Silvert" <ssilvert at redhat.com>
> >> To: keycloak-user at lists.jboss.org
> >> Sent: Wednesday, 21 May, 2014 7:44:49 PM
> >> Subject: [keycloak-user] Exporting a realm
> >>
> >> I see from KEYCLOAK-309 that exporting a realm has been implemented.
> >>
> >> How do I actually do this? Maybe I'm just blind, but I don't see
> >> anything in the UI. Is there a command line tool for it?
> >>
> >> Stan
> >> _______________________________________________
> >> keycloak-user mailing list
> >> keycloak-user at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/keycloak-user
> >>
>
>
More information about the keycloak-user
mailing list