# Initialising a dataset

**URL:** <https://talk.openmrs.org/t/initialising-a-dataset/27925>\
**Category:** Development\
**Created:** [April 12, 2020, 3:30pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925 "2020-04-12T15:30:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 12, 2020, 3:30pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/1 "2020-04-12T15:30:36Z")

</div>

Am having an error when initialising a dataset for my tests which I am failing to figure out a solution.The dataset was loading well until I introduced this obs [https://github.com/METS-Programme/openmrs-module-aijar/pull/487/commits/1cefa98c272e83ab0604c1b7aaf5b978733b7b14#diff-36ac744089526d455a8abca7d5d6d512R23](https://github.com/METS-Programme/openmrs-module-aijar/pull/487/commits/1cefa98c272e83ab0604c1b7aaf5b978733b7b14#diff-36ac744089526d455a8abca7d5d6d512R23) This is strange to me because the one am introducing is very similar to [https://github.com/METS-Programme/openmrs-module-aijar/pull/487/commits/1cefa98c272e83ab0604c1b7aaf5b978733b7b14#diff-36ac744089526d455a8abca7d5d6d512R20](https://github.com/METS-Programme/openmrs-module-aijar/pull/487/commits/1cefa98c272e83ab0604c1b7aaf5b978733b7b14#diff-36ac744089526d455a8abca7d5d6d512R20) .The entire PR is [https://github.com/METS-Programme/openmrs-module-aijar/pull/487/commits/1cefa98c272e83ab0604c1b7aaf5b978733b7b14#diff-8ad1669a2141e05686ac84123fafa4aeR41](https://github.com/METS-Programme/openmrs-module-aijar/pull/487/commits/1cefa98c272e83ab0604c1b7aaf5b978733b7b14#diff-8ad1669a2141e05686ac84123fafa4aeR41) The error can be seen here [https://travis-ci.org/github/METS-Programme/openmrs-module-aijar/builds/674075018](https://travis-ci.org/github/METS-Programme/openmrs-module-aijar/builds/674075018)… I wonder what am missing 🤔 @dkayiwa @ssmusoke @ibacher

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 12, 2020, 5:00pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/2 "2020-04-12T17:00:42Z")

</div>

`NULL not allowed for column "STATUS" `. Did you intentionally leave out the `status` field?

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 12, 2020, 5:54pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/3 "2020-04-12T17:54:12Z")

</div>

When I included it as status=FINAL…I got the same error…

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 12, 2020, 6:29pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/4 "2020-04-12T18:29:56Z")

</div>

Can you do the same for the rest of the obs rows in that dataset file?

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 13, 2020, 6:56am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/5 "2020-04-13T06:56:13Z")

</div>

A new error here still related to my new concept [https://travis-ci.org/github/METS-Programme/openmrs-module-aijar/builds/674285824#L4418](https://travis-ci.org/github/METS-Programme/openmrs-module-aijar/builds/674285824#L4418)

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 13, 2020, 9:45am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/6 "2020-04-13T09:45:33Z")

</div>

`Referential integrity constraint violation: "FK_4T2S7IO9VTX85L7LA56ITT51U: PUBLIC.OBS FOREIGN KEY(CONCEPT_ID) REFERENCES PUBLIC.CONCEPT(CONCEPT_ID) (5096)`

This looks like you are using a non existing concept.

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 13, 2020, 10:28am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/7 "2020-04-13T10:28:59Z")

</div>

Thanks @dkayiwa ur very right, I have been able to solve it with the help of @ssmusoke…I hadn’t added the concept…

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 13, 2020, 1:36pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/8 "2020-04-13T13:36:26Z")

</div>

@dkayiwa I seem to have a new challenge while firing an http request at this line…The error seems to suggest that the controller can’t be found…Is there an issue with my annotation or a different issue entirely that am not seeing…errors at [https://travis-ci.org/github/METS-Programme/openmrs-module-aijar/builds/674407086](https://travis-ci.org/github/METS-Programme/openmrs-module-aijar/builds/674407086)

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 13, 2020, 3:10pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/9 "2020-04-13T15:10:44Z")

</div>

The controller is found. The problem is with your controller’s GET method return type `AppointmentController.getNumberOfPatients’

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 14, 2020, 7:35am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/10 "2020-04-14T07:35:08Z")

</div>

Thanks @dkayiwa makes all the difference…Had not added the annotation of @ResponseBody and correct returnType class…

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 27, 2020, 7:36am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/11 "2020-04-27T07:36:05Z")

</div>

@dkayiwa I have a new followup challenge. My controller seems to be serving the purpose at least as far as the unit test goes…However when I try to integrate the module into a distro: Initializing EhCache CacheManager takes a long time and still the server fails to start with the following errors. [https://pastebin.com/XBa2DGw7](https://pastebin.com/XBa2DGw7) This failure seems to follow the annotation of Controller on my rest-bean [https://github.com/METS-Programme/openmrs-module-aijar/pull/487/files#diff-c21952d28dd2fa48dcfede5f2077cf68R21](https://github.com/METS-Programme/openmrs-module-aijar/pull/487/files#diff-c21952d28dd2fa48dcfede5f2077cf68R21). If I make this a component then the server builds…What could i be missing.

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 27, 2020, 10:44am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/12 "2020-04-27T10:44:56Z")

</div>

The log you shared is not related to your controller. Do you have anything after it? And by the way, did you get a chance to look at this? [https://wiki.openmrs.org/display/docs/Adding+a+Web+Service+Step+by+Step+Guide+for+Module+Developers](https://wiki.openmrs.org/display/docs/Adding+a+Web+Service+Step+by+Step+Guide+for+Module+Developers)

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 27, 2020, 10:50am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/13 "2020-04-27T10:50:51Z")

</div>

@dkayiwa Unfortunately, I didnt have any logs related to the controller.

> [@dkayiwa](#):
>
> [Adding a Web Service Step by Step Guide for Module Developers - Documentation - OpenMRS Wiki](https://wiki.openmrs.org/display/docs/Adding+a+Web+Service+Step+by+Step+Guide+for+Module+Developers)

I did look at it but since I was creating an end point which isn’t a resource in Openmrs I followed a pattern seen in some modules for example [https://github.com/openmrs/openmrs-module-attachments/blob/master/omod-1.10/src/main/java/org/openmrs/module/attachments/rest/AttachmentBytesResource1\_10.java#L32](https://github.com/openmrs/openmrs-module-attachments/blob/master/omod-1.10/src/main/java/org/openmrs/module/attachments/rest/AttachmentBytesResource1_10.java#L32) and [https://github.com/openmrs/openmrs-module-emrapi/blob/master/omod/src/main/java/org/openmrs/module/emrapi/web/controller/ActiveVisitController.java#L25](https://github.com/openmrs/openmrs-module-emrapi/blob/master/omod/src/main/java/org/openmrs/module/emrapi/web/controller/ActiveVisitController.java#L25)

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 27, 2020, 11:05am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/14 "2020-04-27T11:05:25Z")

</div>

The first thing to fix is, ensure that all your references to the rest webservices module in pom.xml have the scope of `provided` or `test` as necessary. Then compile, run and tell me if you still have the same problem.

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 27, 2020, 2:34pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/15 "2020-04-27T14:34:29Z")

</div>

@dkayiwa I have been trying to add scope to the webservices dependencies however the classes throw errors when I do so. Not sure if there is a plugin in the pom that stops this or something else. This being said: I have been able to go past the earlier hung at Initializing EhCache CacheManager when I refined the pom. [https://github.com/METS-Programme/openmrs-module-aijar/pull/487/files](https://github.com/METS-Programme/openmrs-module-aijar/pull/487/files) but now I get errors when the server has started and I try to access the homePage. [https://pastebin.com/4Xhb90DL](https://pastebin.com/4Xhb90DL)

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 27, 2020, 2:50pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/16 "2020-04-27T14:50:42Z")

</div>

Are all your changes committed?

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 28, 2020, 11:45am UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/17 "2020-04-28T11:45:22Z")

</div>

@dkayiwa yes they are…

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 28, 2020, 2:37pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/18 "2020-04-28T14:37:54Z")

</div>

@reagan i did not mean that you remove the rest webservices dependencies. But rather that those which do not have scope get it as `<scope>provided</scope>`

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [April 28, 2020, 3:32pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/19 "2020-04-28T15:32:46Z")

</div>

@dkayiwa whenever I try to do that…I end up with errors in the controller and unit test class…

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 28, 2020, 3:40pm UTC](https://talk.openmrs.org/t/initialising-a-dataset/27925/20 "2020-04-28T15:40:31Z")

</div>

@reagan what exact changes did you make? I do not expect adding scope provided to dependencies that did not have any scope before, to lead into test failures.

[Next page](https://talk.openmrs.org/t/initialising-a-dataset/27925.md?page=2)
