Null Pointer Excaption when calling the api

So I created my own table in the database and am tring to retrieve all the values in it in a List.I have created all the DAOs,services and implementation.But when I call the url for the api,I get the following error:

https://pastebin.com/70hZzTiU

@krishnanspace can you give the details of your api?here

I have a table called krish_patient_table in the DB.The api will retrieve all the records from the table and show it.This is my url for the api:http://localhost:8080/openmrs/ws/rest/getpats

@krishnanspace that’s for your localhost i don’t think it’s accessible?And did you have to introduce a new table,i believe you only needed to use the service layer and if any.

Yes.I created my new table.Should I upload my code to Github?

1 Like

Many time when the server throws a NPE,it means either the table does not exist or there is a problem with your dao’s or service layer,but again OpenMRS code base has most of these things crafted.Yes you can upload to Github


Here you go

Replace SessionFactory with DBsessionFactory at https://github.com/krishnanspace/sample-openmrs-db/blob/master/api/src/main/java/org/openmrs/module/basicmodule/dao/impl/GetPatDaoImpl.java

How do I import DBSessionFactory into my code?