# Data Migration Java Swing Utility for NigeriaMRS

**URL:** <https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248>\
**Category:** Development\
**Tags:** developers-forum\
**Created:** [May 31, 2018, 12:30am UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248 "2018-05-31T00:30:57Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![brightoibe](https://talk.openmrs.org/letter_avatar/brightoibe/32/6_22734026db12803ebb3e059622ac3534.png) [@brightoibe](https://talk.openmrs.org/u/brightoibe)\
**Post date:** [May 31, 2018, 12:30am UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/1 "2018-05-31T00:30:57Z")

</div>

Am trying to connect to the openmrs server using a Java utility to migrate data from OpenMRS 1.8.2 to OpenMRS refrence app 2.6. I have included dependencies in my pom.xml but am having this error.

Exception in thread “AWT-EventQueue-0” java.lang.NoClassDefFoundError: org/openmrs/util/DatabaseUpdateException at controller.ImportController.(ImportController.java:23) at view.MigratorJFrame.(MigratorJFrame.java:108) at view.MigratorJFrame$5.run(MigratorJFrame.java:506) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) Caused by: java.lang.ClassNotFoundException: org.openmrs.util.DatabaseUpdateException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) … 17 more

---

<div class="post-metadata">

**Author:** ![brightoibe](https://talk.openmrs.org/letter_avatar/brightoibe/32/6_22734026db12803ebb3e059622ac3534.png) [@brightoibe](https://talk.openmrs.org/u/brightoibe)\
**Post date:** [May 31, 2018, 4:59am UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/2 "2018-05-31T04:59:06Z")

</div>

Context.startup(“jdbc:mysql://localhost:3306/server2?autoReconnect=true”, username, pass, new Properties());

Keeps throwing exception

---

<div class="post-metadata">

**Author:** ![brightoibe](https://talk.openmrs.org/letter_avatar/brightoibe/32/6_22734026db12803ebb3e059622ac3534.png) [@brightoibe](https://talk.openmrs.org/u/brightoibe)\
**Post date:** [May 31, 2018, 4:11pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/3 "2018-05-31T16:11:53Z")

</div>

ERROR - Context.getServiceContext(250) |2018-05-31 17:04:51,044| serviceContext is null. Creating new ServiceContext() Exception in thread “Thread-2” org.openmrs.api.APIException: Service not found: interface org.openmrs.messagesource.MessageSourceService

The is what am getting now

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [May 31, 2018, 5:27pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/4 "2018-05-31T17:27:11Z")

</div>

With this new exception it probably means that there’s a deeper root cause exception that you can find in the logs, and you’d need to share. Also, I suggest that if you’re asking for dev help then you should post this in the #dev category (since most developers aren’t watching Local categories that they’re not engaged with).

---

<div class="post-metadata">

**Author:** ![ssmusoke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ssmusoke/32/8020_2.png) [@ssmusoke](https://talk.openmrs.org/u/ssmusoke)\
**Post date:** [May 31, 2018, 5:57pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/5 "2018-05-31T17:57:04Z")

</div>

@brightoibe Why don’t you just dump the data using

`mysqldump -u root -p server2 > backup.sql`

---

<div class="post-metadata">

**Author:** ![brightoibe](https://talk.openmrs.org/letter_avatar/brightoibe/32/6_22734026db12803ebb3e059622ac3534.png) [@brightoibe](https://talk.openmrs.org/u/brightoibe)\
**Post date:** [June 1, 2018, 12:52am UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/6 "2018-06-01T00:52:28Z")

</div>

Thanks @ssmusoke. But what am trying to do is to build a small desktop utility that will migrate data from OpenMRS 1.8.2 to OpenMRS refrence app 2.6. The data models and the concepts are quite different. Am tring to connect the Java Swing app to the refrence app and upload the data in csv format.

---

<div class="post-metadata">

**Author:** ![ssmusoke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ssmusoke/32/8020_2.png) [@ssmusoke](https://talk.openmrs.org/u/ssmusoke)\
**Post date:** [June 1, 2018, 9:00am UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/7 "2018-06-01T09:00:21Z")

</div>

What we did for UgandaEMR was to develop an SQL migration script which is executed via a batch file, [https://github.com/METS-Programme/openmrs-module-aijar/blob/master/tools/src/main/resources/upgrade/updatedatabase\_1\_9\_x.bat](https://github.com/METS-Programme/openmrs-module-aijar/blob/master/tools/src/main/resources/upgrade/updatedatabase_1_9_x.bat)

This eliminates the need to develop a custom Java utility to do the same. As long as you can get a connection to the database

---

<div class="post-metadata">

**Author:** ![wyclif](https://talk.openmrs.org/user_avatar/talk.openmrs.org/wyclif/32/19607_2.png) [@wyclif](https://talk.openmrs.org/u/wyclif)\
**Post date:** [June 1, 2018, 1:19pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/8 "2018-06-01T13:19:52Z")

</div>

> [@brightoibe](#):
>
> But what am trying to do is to build a small desktop utility that will migrate data from OpenMRS 1.8.2 to OpenMRS refrence app 2.6

Not sure why you have to do this, there is already an upgrade mechanism in OpenMRS that does this for you.

---

<div class="post-metadata">

**Author:** ![brightoibe](https://talk.openmrs.org/letter_avatar/brightoibe/32/6_22734026db12803ebb3e059622ac3534.png) [@brightoibe](https://talk.openmrs.org/u/brightoibe)\
**Post date:** [June 1, 2018, 1:33pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/9 "2018-06-01T13:33:37Z")

</div>

Thanks @wyclif. Will love to see it. My fear is that the concept dictionary of the OpenMRS 1.8.2 is very different from the concept dictionary of the OpenMRS reference app 2.7. If the upgrade mechanism will take care of this, I will be very happy to have it. Please can you shear a link? We have over 200+ sites running OpenMRS 1.8.2 and i need something automated and user friendly.

---

<div class="post-metadata">

**Author:** ![brightoibe](https://talk.openmrs.org/letter_avatar/brightoibe/32/6_22734026db12803ebb3e059622ac3534.png) [@brightoibe](https://talk.openmrs.org/u/brightoibe)\
**Post date:** [June 1, 2018, 1:36pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/10 "2018-06-01T13:36:22Z")

</div>

Thanks for sharing @ssmusoke Will take a look. But note that the concept dictionaries for the OpenMRS 1.8.2 is very different from that of the refrence app 2.7 which is now built around openlabconcepts.

---

<div class="post-metadata">

**Author:** ![brightoibe](https://talk.openmrs.org/letter_avatar/brightoibe/32/6_22734026db12803ebb3e059622ac3534.png) [@brightoibe](https://talk.openmrs.org/u/brightoibe)\
**Post date:** [June 1, 2018, 1:45pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/11 "2018-06-01T13:45:59Z")

</div>

Thanks @darius. I just want to write a java program to ;

1. Read a CSV or XML file exported from OpenMRS 1.8.2
2. Connect to OpenMRS reference app 2.7 using openlab concepts (different dictionary)
3. Import the CSV into OpenMRS using openmrs api in batch processing
4. Validate and reject dirty data.
5. The utility will be external to OpenMRS and will be discontinued after the imports.

Some of our sites have high patient load and we have about 200+ sites running the OpenMRS 1.8.2. All I need is a simple class with a main method and a pom.xml file that illustrates basic connection to the refrence app from a standalone lightweigh java app. I am open to learn short cuts and new ideas if this is not nessasary.

---

<div class="post-metadata">

**Author:** ![wyclif](https://talk.openmrs.org/user_avatar/talk.openmrs.org/wyclif/32/19607_2.png) [@wyclif](https://talk.openmrs.org/u/wyclif)\
**Post date:** [June 1, 2018, 1:56pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/12 "2018-06-01T13:56:44Z")

</div>

@brightoibe as I said, the upgrade scripts will take care of updating the concept related tables and the data will be updated automatically, you don’t have to do it, the reference application assumes a CIEL dictionary and to load that all you need to do is to source the appropriate CIEL SQL dump file.

---

<div class="post-metadata">

**Author:** ![ssmusoke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ssmusoke/32/8020_2.png) [@ssmusoke](https://talk.openmrs.org/u/ssmusoke)\
**Post date:** [June 1, 2018, 2:11pm UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/13 "2018-06-01T14:11:41Z")

</div>

@brightoibe you should not be worried about the concept dictionary differences, as your app should still work with whatever concepts you have. The concept dictionary is just a reference guide - your data is what matters.

---

<div class="post-metadata">

**Author:** ![brightoibe](https://talk.openmrs.org/letter_avatar/brightoibe/32/6_22734026db12803ebb3e059622ac3534.png) [@brightoibe](https://talk.openmrs.org/u/brightoibe)\
**Post date:** [June 3, 2018, 11:00am UTC](https://talk.openmrs.org/t/data-migration-java-swing-utility-for-nigeriamrs/18248/14 "2018-06-03T11:00:28Z")

</div>

[https://pastebin.com/0nhn1f0b](https://pastebin.com/0nhn1f0b)
