[keycloak-user] Exporting a realm

Stan Silvert ssilvert at redhat.com
Thu May 22 10:35:34 EDT 2014


Much better now.  I still get this error, but it doesn't seem to cause 
any problems.

10:29:45,515 INFO  [org.keycloak.exportimport.ModelImporter] (MSC 
service thread 1-10) Realms imported: [RealmEntity [ id=keycloak-admin 
], RealmEntity [ id=6b542ab8-cfec
-448f-99a7-2ef7c8b67083 ]]
10:29:45,557 INFO  [org.keycloak.exportimport.ModelImporter] (MSC 
service thread 1-10) Applications imported: [ApplicationEntity [ 
id=1f77b80d-aedf-49d2-9dbb-45690cc5fd5d
  ], ApplicationEntity [ id=b3c41eec-3410-4cef-bef7-c71846e35436 ], 
ApplicationEntity [ id=5e6ea6ff-2e65-439b-8926-7cc13b89d090 ], 
ApplicationEntity [ id=725e74ec-87f1-436
7-bbbe-44f6555e70a4 ], ApplicationEntity [ 
id=066cf749-99c7-4dbc-b371-ead89875371e ], ApplicationEntity [ 
id=869667f9-49a5-4e78-8044-f62c33e0d9cb ], ApplicationEntity [ i
d=76565b4e-0241-40be-8618-7d679cf7af59 ], ApplicationEntity [ 
id=a403dc15-cfb6-48d6-89e6-37a5d25700ad ], ApplicationEntity [ 
id=6cc241a0-3bee-4a3c-af0f-1971903b31ac ]]
LogManager error of type FORMAT_FAILURE: Formatting error
java.util.IllegalFormatConversionException: d != java.util.Arrays$ArrayList
         at java.util.Formatter$FormatSpecifier.failConversion(Unknown 
Source)
         at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
         at java.util.Formatter$FormatSpecifier.print(Unknown Source)
         at java.util.Formatter.format(Unknown Source)
         at java.util.Formatter.format(Unknown Source)
         at java.lang.String.format(Unknown Source)
         at 
org.jboss.logmanager.ExtLogRecord.formatRecord(ExtLogRecord.java:434)
         at 
org.jboss.logmanager.ExtLogRecord.getFormattedMessage(ExtLogRecord.java:397)
         at 
org.jboss.logmanager.formatters.Formatters$10.renderRaw(Formatters.java:568)
         at 
org.jboss.logmanager.formatters.Formatters$JustifyingFormatStep.render(Formatters.java:225)
         at 
org.jboss.logmanager.formatters.MultistepFormatter.format(MultistepFormatter.java:86)
         at org.jboss.logmanager.ExtFormatter.format(ExtFormatter.java:35)
         at 
org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:49)
         at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:79)
         at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:296)
         at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:304)
         at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:304)
         at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:304)
         at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:304)
         at org.jboss.logmanager.Logger.logRaw(Logger.java:721)
         at org.jboss.logmanager.Logger.log(Logger.java:672)
         at 
org.jboss.logging.JBossLogManagerLogger.doLogf(JBossLogManagerLogger.java:50)
         at org.jboss.logging.Logger.infof(Logger.java:842)
         at 
org.keycloak.exportimport.ModelImporter.importRoles(ModelImporter.java:154)
         at 
org.keycloak.exportimport.ModelImporter.importModel(ModelImporter.java:60)
         at 
org.keycloak.exportimport.ExportImportProviderImpl.checkExportImport(ExportImportProviderImpl.java:50)
         at 
org.keycloak.services.resources.KeycloakApplication.checkExportImportProvider(KeycloakApplication.java:247)
         at 
org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:87)
         at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at 
org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:148)
         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)
         at 
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown 
Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown 
Source)
         at java.lang.Thread.run(Unknown Source)
10:29:45,956 INFO  [org.keycloak.exportimport.ModelImporter] (MSC 
service thread 1-10) OAuth clients imported: []
10:29:46,025 INFO  [org.keycloak.exportimport.ModelImporter] (MSC 
service thread 1-10) 3 users imported:
10:29:46,027 INFO [org.keycloak.exportimport.ExportImportProviderImpl] 
(MSC service thread 1-10) Import finished successfully

On 5/22/2014 10:18 AM, Stan Silvert wrote:
> I'm using master, but what I've got is a few days old.  I'll update and
> try again.
>
> On 5/22/2014 10:03 AM, Stian Thorgersen wrote:
>> 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
>>>>>
> _______________________________________________
> 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