Error when importing metadata

Dear All,

I have exported the metadata of a program from one DHIS2 Instance. i want to import it into the other instance. When i do “dry run”, it shows no error. But when i do the actual import, i get the below error:

TypeError: Cannot read properties of undefined (reading 'imported')
TypeError: Cannot read properties of undefined (reading 'imported')
    at gt (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/app.721376d2.chunk.js:1:516997)
    at Gi (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:626080)
    at _s (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:672310)
    at vl (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:665037)
    at ml (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:664962)
    at sl (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:661971)
    at https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:613342
    at t.unstable_runWithPriority (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:688741)
    at Va (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:613051)
    at Ka (https://ohsp.health.gov.mw/dhis-web-import-export/static/js/138.7078e649.chunk.js:2:613287)
    in gt
    in div
    in It
    in div
    in Et
    in div
    in Gn
    in div
    in qt
    in vi
    in n
    in n
    in Gl
    in ql
    in main
    in div
    in n
    in n
    in Unknown
    in Suspense
    in be
    in div
    in div
    in _e
    in qe
    in C
    in de
    in je
    in le
    in DHIS2RuntimeProvider
    in Ne
    in be
    in Le
    in i

How can i resolve the problem?

Thanks in advance

Hi @emmanuellmhango

Please share the following information:

  1. DHIS2 Version
  2. Template which you use to upload to the instance so that I can use on play.dhis2.org to see if the error is reproduced.

Thanks!

Dear Al-Gassim,
Version: 2.38.3.1
metadata (1).json (239.3 KB)

Dear @emmanuellmhango
This is unfortunately a quite common problem in later versions of DHIS2. What is happening is that the back-end server is throwing some error (very likely a constraint violation) which the front-end client does not handle very well. The “dry run” functionality does not catch all potential metadata issues, and these only may become apparent when you actually try and write the metadata to the database.

So, in order to determine what is going on, you are going to need to open up the developer tools of your browser, and try and find the actual error when you upload the metadata to the server. That should give you a better clue about what is going on. The other alternative (if you have access to the backend server) is to monitor the logs for the error. Likely, it is related to a constraint violation.

Let us know how it goes.

Regards,
Jason

4 Likes

Hello, I hope its not too late to reply to this thread,

I am experiencing the same error when trying to move a tracker program from one instance to another,

Note that both instances are running 2.40.3 with the target instance running 2.40.3.2.

After checking the catalina logs, the error i am getting is listed below:

Updating 3 object(s) of type Option (DefaultObjectBundleService.java [taskScheduler-15])

  • INFO 2024-06-28T03:46:46,508 () Updating 3 object(s) of type Option (NotificationLoggerUtil.java [taskScheduler-15])
  • ERROR 2024-06-28T03:46:46,524 java.lang.NullPointerException: Cannot invoke “org.hisp.dhis.option.Option.getSortOrder()” because “thisOption” is null
    at org.hisp.dhis.option.OptionSet.addOption(OptionSet.java:90)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

however after sometime the import gives this response

Import:Start (DefaultMetadataImportService.java [taskScheduler-18])

  • INFO 2024-06-28T03:52:31,177 () Import:Start (NotificationLoggerUtil.java [taskScheduler-18])
  • INFO 2024-06-28T03:52:31,996 () Import:Preheat[REFERENCE] took 0.815535 sec. (DefaultPreheatService.java [taskScheduler-18])
  • INFO 2024-06-28T03:52:32,061 () Import:Validation took 0.023181 sec. (DefaultObjectBundleValidationService.java [taskScheduler-18])
  • INFO 2024-06-28T03:52:32,061 () Import:Commit took 0.000042 sec. (DefaultMetadataImportService.java [taskScheduler-18])
  • INFO 2024-06-28T03:52:32,061 () Import:Done took 0.884946 sec. (DefaultMetadataImportService.java [taskScheduler-18])
  • INFO 2024-06-28T03:52:32,061 () Import:Done took 0.884946 sec. (NotificationLoggerUtil.java [taskScheduler-18])
1 Like

Thanks ALL for the answers.

I found out the error. it seems when we are exporting it includes empty optionsets which gives out errors when importing.
so going to the exported metadata and removing these empty optionsets

regards

1 Like

Am also facing an import error when importing org unit metadata between two similar versions of DHIS2

Log
  • INFO 2024-07-10T15:45:31,246 Import done: 00:00:00.475 (Clock.java [http-nio-8080-exec-14]) IDwxo1kfC5DEoF3iinM3ucq79dbLhK/mYWOJWWrHBGR7w=
  • ERROR 2024-07-10T15:45:31,920 java.lang.IllegalStateException: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.hisp.dhis.organisationunit.OrganisationUnit
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:151)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
    at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1411)
    at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1394)
    at org.hisp.dhis.dbms.HibernateDbmsManager.clearSession(HibernateDbmsManager.java:360)
    at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundleService.commit(DefaultObjectBundleService.java:146)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:241)
    at jdk.proxy3/jdk.proxy3.$Proxy328.commit(Unknown Source)
    at org.hisp.dhis.dxf2.metadata.DefaultMetadataImportService.importMetadata(DefaultMetadataImportService.java:125)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:241)
    at jdk.proxy3/jdk.proxy3.$Proxy330.importMetadata(Unknown Source)
    at org.hisp.dhis.webapi.controller.metadata.MetadataAsyncImporter.call(MetadataAsyncImporter.java:73)
    at org.hisp.dhis.security.SecurityContextRunnable.run(SecurityContextRunnable.java:53)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
    Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.hisp.dhis.organisationunit.OrganisationUnit
    at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:347)
    at org.hibernate.type.EntityType.getIdentifier(EntityType.java:508)
    at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:370)
    at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:381)
    at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:330)
    at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:4768)
    at org.hibernate.event.internal.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:586)
    at org.hibernate.event.internal.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:249)
    at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:174)
    at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
    at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:229)
    at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:93)
    at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
    at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
    at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1407)
    … 39 more
    (MetadataAsyncImporter.java [taskScheduler-23])
  • ERROR 2024-07-10T15:45:31,921 Process failed: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.hisp.dhis.organisationunit.OrganisationUnit (NotificationLoggerUtil.java [taskScheduler-23])

Hi @omunyao
How are you importing the metadata? Which app are you using and which version of DHIS2?

Please try to clear system cache first from Data Administration app, Maintenance then try again.

In the log it only shows that there’s an issue with the OUs metadata, does it mention other metadata? Could you double check that OUs are all configured well and that there’s no OU cache or temporary deletions?

Thanks!

I ran into this same error but when I unchecked everything under the mapping section and also the"ApiToken" under the other section it worked!

1 Like