dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #49024
Re: Exception when importing User and User Role metadata in 2.24
Hi,
I have tracked this down. In the User xml object, within the embedded
UserCredentials object, there is an embedded User object. It appears this
"user" object is meant to be the user that created the UserCredentials.
In some of the entries, it is the user itself that is contained in the
embedded instance. In other entries, it contains a user that is elsewhere
in the xml file to be imported.
In order to allow the import to run without exceptions, I need to either
delete this embedded user object, or change it to a user that already
exists in the system prior to the import.
I basically have to delete all the embedded User objects, import the file,
then revert the deletion, and import the file again as an update.
Below is an example of what is being exported.
Is this expected behaviour? Is there any way that these cases can be
handled by the app, and not throw an exception? I am doing a straight
export from one instance to another, both of which are running the same
DHIS 2 version and build.
Thanks,
Lorill
<?xml version='1.0' encoding='UTF-8'?>
<metaData xmlns="http://dhis2.org/schema/dxf/2.0"
created="2017-03-30T20:22:15.342+0000">
<users>
<user name="xxx" created="2015-06-07T11:59:59.183+0000"
lastUpdated="2015-06-07T11:59:59.183+0000"
id="UomqXpvKh8M">
<externalAccess>false</externalAccess>
<surname>xxx</surname>
<firstName>xxx</firstName>
<email>xxx@xxxxxxxxx</email>
<userCredentials code="xxx" name="xxx"
created="2015-06-07T11:59:59.033+0000"
lastUpdated="2016-04-04T21:06:22.000+0000"
id="B8sCr5nOWro">
<externalAccess>false</externalAccess>
* <user name="xxx" created="2015-06-07T11:59:59.183+0000"*
* lastUpdated="2015-06-07T11:59:59.183+0000"
id="UomqXpvKh8M">*
* <externalAccess>false</externalAccess>*
* </user>*
<username>xxx</username>
<externalAuth>false</externalAuth>
<password>$2a$10$.nZpxupXABUpy3RNpAl.8uSg2OSsnZgxtSHKDTwjhTTPprSZ5W3vK</password>
<passwordLastUpdated>2015-06-07T11:59:59.034+0000</passwordLastUpdated>
<lastLogin>2015-12-22T13:35:41.507+0000</lastLogin>
<selfRegistered>false</selfRegistered>
<invitation>false</invitation>
<disabled>false</disabled>
<userRoles>
<userRole name="Superuser"
created="2015-05-04T13:43:25.507+0000"
lastUpdated="2017-03-08T22:03:03.771+0000"
id="cjBTUmG9C9K">
<externalAccess>false</externalAccess>
<publicAccess>--------</publicAccess>
<user name="yyy"
created="2015-05-29T06:54:42.002+0000"
lastUpdated="2015-06-02T20:16:52.617+0000"
id="BcLOMAHqNDV">
<externalAccess>false</externalAccess>
</user>
</userRole>
</userRoles>
</userCredentials>
<organisationUnits>
<organisationUnit code="malawi" name="Malawi"
created="2013-06-10T18:34:22.000+0000"
lastUpdated="2016-02-18T21:28:15.763+0000" id="lZsCb6y0KDX">
<externalAccess>false</externalAccess>
</organisationUnit>
</organisationUnits>
<dataViewOrganisationUnits>
<dataViewOrganisationUnit code="malawi" name="Malawi"
created="2013-06-10T18:34:22.000+0000"
lastUpdated="2016-02-18T21:28:15.763+0000" id="lZsCb6y0KDX">
<externalAccess>false</externalAccess>
</dataViewOrganisationUnit>
</dataViewOrganisationUnits>
</user>
</users>
</metaData>
On Wed, Mar 29, 2017 at 1:42 AM, Marc Garnica <marcgarnica13@xxxxxxxxx>
wrote:
> I assume you are not importing the user with which you are logged in,
> right? This might be the reason.. If not I don't have any clear idea.
>
> Marc Garnica
>
> 2017-03-29 0:56 GMT+02:00 Lorill Crees <lcrees@xxxxxxxxxx>:
>
>> Hi,
>>
>> I am attempting to set up a new empty 2.24 database and populate it with
>> an export of Org units and Users and User Roles from a different 2.24
>> database. I exported in xml format, with 2 separate export files for:
>>
>> 1. Org units / Org Unit Groups / Org Unit Group Sets / Org Unit Levels
>> 2. Users / User Groups / User Roles
>>
>>
>> I am able to import the org units just fine. However, when I attempt to
>> import the User/User Role xml file I get an exception and the metadata
>> import halts (stacktrace below).
>>
>> Both instances are running the exact same version of 2.24:
>>
>> Version:
>> 2.24
>> Build revision:
>> 294f578
>> Build date:
>> 2017-03-20 06:21
>>
>> Note that doing a dry run import shows successfully importing 19 users
>> and 2 UserRoles.
>>
>> Also note that doing the export and import via json has the same result.
>>
>> Any help resolving this would be appreciated.
>>
>> Thanks,
>>
>> Lorill
>>
>> * INFO 2017-03-28 15:20:37,221 [Level: INFO, category: METADATA_IMPORT,
>> time: Tue Mar 28 15:20:37 PDT 2017, message: Importing 19 Users]
>> (InMemoryNotifier.java [taskScheduler-4])
>>
>> * INFO 2017-03-28 15:20:37,259 'admin' create org.hisp.dhis.user.User,
>> name: xxx, uid: spw11k0SXjJ (AuditLogUtil.java [taskScheduler-4])
>>
>> * INFO 2017-03-28 15:20:37,281 'admin' update org.hisp.dhis.user.User,
>> name: xxx, uid: spw11k0SXjJ (AuditLogUtil.java [taskScheduler-4])
>>
>> * INFO 2017-03-28 15:20:37,445 'admin' update org.hisp.dhis.user.User,
>> name: xxx, uid: spw11k0SXjJ (AuditLogUtil.java [taskScheduler-4])
>>
>> * ERROR 2017-03-28 15:20:37,460 Unexpected error occurred in scheduled
>> task. (TaskUtils.java [taskScheduler-4])
>>
>> org.hibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing:
>> org.hisp.dhis.user.User
>>
>> at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifie
>> rIfNotUnsaved(ForeignKeys.java:279)
>>
>> at org.hibernate.type.EntityType.getIdentifier(EntityType.java:455)
>>
>> at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:281)
>>
>> at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:291)
>>
>> at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:296)
>>
>> at org.hibernate.persister.entity.AbstractEntityPersister.findD
>> irty(AbstractEntityPersister.java:4126)
>>
>> at org.hibernate.event.internal.DefaultFlushEntityEventListener
>> .dirtyCheck(DefaultFlushEntityEventListener.java:528)
>>
>> at org.hibernate.event.internal.DefaultFlushEntityEventListener
>> .isUpdateNecessary(DefaultFlushEntityEventListener.java:215)
>>
>> at org.hibernate.event.internal.DefaultFlushEntityEventListener
>> .onFlushEntity(DefaultFlushEntityEventListener.java:142)
>>
>> at org.hibernate.event.internal.AbstractFlushingEventListener.f
>> lushEntities(AbstractFlushingEventListener.java:216)
>>
>> at org.hibernate.event.internal.AbstractFlushingEventListener.f
>> lushEverythingToExecutions(AbstractFlushingEventListener.java:85)
>>
>> at org.hibernate.event.internal.DefaultAutoFlushEventListener.o
>> nAutoFlush(DefaultAutoFlushEventListener.java:44)
>>
>> at org.hibernate.internal.SessionImpl.autoFlushIfRequired(Sessi
>> onImpl.java:1264)
>>
>> at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1332)
>>
>> at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
>>
>> at org.hibernate.internal.AbstractQueryImpl.uniqueResult(Abstra
>> ctQueryImpl.java:964)
>>
>> at org.hisp.dhis.user.hibernate.HibernateCurrentUserStore.getUs
>> erCredentialsByUsername(HibernateCurrentUserStore.java:55)
>>
>> at org.hisp.dhis.user.DefaultCurrentUserService.getCurrentUser(
>> DefaultCurrentUserService.java:93)
>>
>> at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)
>>
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>> thodAccessorImpl.java:43)
>>
>> at java.lang.reflect.Method.invoke(Method.java:483)
>>
>> at org.springframework.aop.support.AopUtils.invokeJoinpointUsin
>> gReflection(AopUtils.java:302)
>>
>> 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.TransactionInter
>> ceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
>>
>> at org.springframework.transaction.interceptor.TransactionAspec
>> tSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
>>
>> at org.springframework.transaction.interceptor.TransactionInter
>> ceptor.invoke(TransactionInterceptor.java:96)
>>
>> at org.springframework.aop.framework.ReflectiveMethodInvocation
>> .proceed(ReflectiveMethodInvocation.java:179)
>>
>> at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
>> JdkDynamicAopProxy.java:208)
>>
>> at com.sun.proxy.$Proxy54.getCurrentUser(Unknown Source)
>>
>> at org.hisp.dhis.hibernate.HibernateGenericStore.getSharingCrit
>> eria(HibernateGenericStore.java:208)
>>
>> at org.hisp.dhis.hibernate.HibernateGenericStore.getSharingCrit
>> eria(HibernateGenericStore.java:202)
>>
>> at org.hisp.dhis.hibernate.HibernateGenericStore.getSharingCrit
>> eria(HibernateGenericStore.java:287)
>>
>> at org.hisp.dhis.hibernate.HibernateGenericStore.getSharingObje
>> ct(HibernateGenericStore.java:319)
>>
>> at org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectSt
>> ore.getByUid(HibernateIdentifiableObjectStore.java:108)
>>
>> at org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectSt
>> ore.getByUid(HibernateIdentifiableObjectStore.java:58)
>>
>> at org.hisp.dhis.common.DefaultIdentifiableObjectManager.get(De
>> faultIdentifiableObjectManager.java:244)
>>
>> at sun.reflect.GeneratedMethodAccessor465.invoke(Unknown Source)
>>
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>> thodAccessorImpl.java:43)
>>
>> at java.lang.reflect.Method.invoke(Method.java:483)
>>
>> at org.springframework.aop.support.AopUtils.invokeJoinpointUsin
>> gReflection(AopUtils.java:302)
>>
>> 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.TransactionInter
>> ceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
>>
>> at org.springframework.transaction.interceptor.TransactionAspec
>> tSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
>>
>> at org.springframework.transaction.interceptor.TransactionInter
>> ceptor.invoke(TransactionInterceptor.java:96)
>>
>> at org.springframework.aop.framework.ReflectiveMethodInvocation
>> .proceed(ReflectiveMethodInvocation.java:179)
>>
>> at org.springframework.aop.interceptor.ExposeInvocationIntercep
>> tor.invoke(ExposeInvocationInterceptor.java:92)
>>
>> at org.springframework.aop.framework.ReflectiveMethodInvocation
>> .proceed(ReflectiveMethodInvocation.java:179)
>>
>> at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
>> JdkDynamicAopProxy.java:208)
>>
>> at com.sun.proxy.$Proxy68.get(Unknown Source)
>>
>> at org.hisp.dhis.dxf2.metadata.DefaultObjectBridge.getUidMatch(
>> DefaultObjectBridge.java:723)
>>
>> at org.hisp.dhis.dxf2.metadata.DefaultObjectBridge.findMatches(
>> DefaultObjectBridge.java:527)
>>
>> at org.hisp.dhis.dxf2.metadata.DefaultObjectBridge.getObjects(D
>> efaultObjectBridge.java:422)
>>
>> at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObj
>> ectImporter.validateIdentifiableObject(DefaultIdentifiableOb
>> jectImporter.java:690)
>>
>> at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObj
>> ectImporter.importObjectLocal(DefaultIdentifiableObjectImporter.java:566)
>>
>> at org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObj
>> ectImporter.importObjects(DefaultIdentifiableObjectImporter.java:191)
>>
>> at org.hisp.dhis.dxf2.metadata.DefaultImportService.doImport(De
>> faultImportService.java:261)
>>
>> at org.hisp.dhis.dxf2.metadata.DefaultImportService.importMetaD
>> ata(DefaultImportService.java:177)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
>> ssorImpl.java:62)
>>
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>> thodAccessorImpl.java:43)
>>
>> at java.lang.reflect.Method.invoke(Method.java:483)
>>
>> at org.springframework.aop.support.AopUtils.invokeJoinpointUsin
>> gReflection(AopUtils.java:302)
>>
>> 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.TransactionInter
>> ceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
>>
>> at org.springframework.transaction.interceptor.TransactionAspec
>> tSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
>>
>> at org.springframework.transaction.interceptor.TransactionInter
>> ceptor.invoke(TransactionInterceptor.java:96)
>>
>> at org.springframework.aop.framework.ReflectiveMethodInvocation
>> .proceed(ReflectiveMethodInvocation.java:179)
>>
>> at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
>> JdkDynamicAopProxy.java:208)
>>
>> at com.sun.proxy.$Proxy241.importMetaData(Unknown Source)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
>> ssorImpl.java:62)
>>
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>> thodAccessorImpl.java:43)
>>
>> at java.lang.reflect.Method.invoke(Method.java:483)
>>
>> at org.springframework.aop.support.AopUtils.invokeJoinpointUsin
>> gReflection(AopUtils.java:302)
>>
>> at org.springframework.aop.framework.ReflectiveMethodInvocation
>> .invokeJoinpoint(ReflectiveMethodInvocation.java:190)
>>
>> at org.springframework.aop.framework.ReflectiveMethodInvocation
>> .proceed(ReflectiveMethodInvocation.java:157)
>>
>> at org.springframework.aop.support.DelegatingIntroductionInterc
>> eptor.doProceed(DelegatingIntroductionInterceptor.java:133)
>>
>> at org.springframework.aop.support.DelegatingIntroductionInterc
>> eptor.invoke(DelegatingIntroductionInterceptor.java:121)
>>
>> at org.springframework.aop.framework.ReflectiveMethodInvocation
>> .proceed(ReflectiveMethodInvocation.java:179)
>>
>> at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
>> JdkDynamicAopProxy.java:208)
>>
>> at com.sun.proxy.$Proxy193.importMetaData(Unknown Source)
>>
>> at org.hisp.dhis.importexport.action.util.ImportMetaDataTask.
>> call(ImportMetaDataTask.java:103)
>>
>> at org.hisp.dhis.security.SecurityContextRunnable.run(SecurityC
>> ontextRunnable.java:57)
>>
>> at org.springframework.scheduling.support.DelegatingErrorHandli
>> ngRunnable.run(DelegatingErrorHandlingRunnable.java:54)
>>
>> at java.util.concurrent.Executors$RunnableAdapter.call(
>> Executors.java:511)
>>
>> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>>
>> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFu
>> tureTask.access$201(ScheduledThreadPoolExecutor.java:180)
>>
>> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFu
>> tureTask.run(ScheduledThreadPoolExecutor.java:293)
>>
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>> Executor.java:1142)
>>
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>> lExecutor.java:617)
>>
>> at java.lang.Thread.run(Thread.java:745)
>> --
>> Lorill Crees
>> Project Leader / Senior Developer
>> 2Paths Solutions Ltd. <http://www.2paths.com>
>>
>> lcrees@xxxxxxxxxx
>> skype: lorill2paths
>> (604) 689-4123 x 15 <(604)%20689-4123>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help : https://help.launchpad.net/ListHelp
>>
>>
>
--
Lorill Crees
Project Leader / Senior Developer
2Paths Solutions Ltd. <http://www.2paths.com>
lcrees@xxxxxxxxxx
skype: lorill2paths
(604) 689-4123 x 15
Follow ups
References