# error: cannot find symbol

**URL:** <https://talk.openmrs.org/t/error-cannot-find-symbol/28323>\
**Category:** Uncategorized\
**Created:** [May 6, 2020, 2:06pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323 "2020-05-06T14:06:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 6, 2020, 2:06pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/1 "2020-05-06T14:06:29Z")

</div>

Hello friends ,  
Am working on TRUNK-4946 with four classes linked on this ticket which handles retiring any object that implements the `Retireable` interface example, [BaseRetireHandler](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/handler/BaseRetireHandler.java). To ensure we don’t write any other data when committing, I had to call the [`Context#refreshEntity()`](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/context/Context.java#L844) function mentioned in the ticket. Making the implementation of `handle()` in the `BaseRetireHandler` to appear like this:

```auto
@Override
public void handle(Retireable retireableObject, User retiringUser, Date retireDate, String retireReason) {

	// reload object from database if it has been saved before
	if (retireableObject.getId() != null) {
		Context.refreshEntity(retireableObject);
	}
	
	// skip over doing retire stuff if already retired
	if (!retireableObject.getRetired() || retireableObject.getRetiredBy() == null) {
		
		retireableObject.setRetired(true);
		retireableObject.setRetireReason(retireReason);
		
		if (retireableObject.getRetiredBy() == null) {
			retireableObject.setRetiredBy(retiringUser);
		}
		if (retireableObject.getDateRetired() == null) {
			retireableObject.setDateRetired(retireDate);
		}
		
	}
	
}

```

Then I added a unit test at the end of the class to verify the behavior: btu when I run `mvn clean install` after saving the changes, I run into this error [https://pastebin.com/PwYEzRn5](https://pastebin.com/PwYEzRn5). I have tried different possible solutions but still running into the same output. I kindly request for help on how to solve this error.

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 6, 2020, 2:24pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/2 "2020-05-06T14:24:04Z")

</div>

Just solve the error by: `import org.openmrs.api.context.Context;`

---

<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:** [May 6, 2020, 2:26pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/3 "2020-05-06T14:26:21Z")

</div>

Next time you can make a commit such that we can relate the line of code referenced in the stack trace to your code…

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 6, 2020, 2:27pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/4 "2020-05-06T14:27:39Z")

</div>

Thanks for the advice .

---

<div class="post-metadata">

**Author:** ![tendomart](https://talk.openmrs.org/user_avatar/talk.openmrs.org/tendomart/32/6753_2.png) [@tendomart](https://talk.openmrs.org/u/tendomart)\
**Post date:** [May 6, 2020, 3:12pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/5 "2020-05-06T15:12:32Z")

</div>

@jwnasambu what do you get when you run debug with “mvn clean install -X” .It look like [ERROR] \Users\JULIE\OpenMRS-Tickets\openmrs-core\api\src\main\java\org\openmrs\api\handler\BaseRetireHandler.java:[59,3] error: cannot find symbol

**BaseRetireHandler.java** is not being seen on the path.

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 6, 2020, 3:18pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/6 "2020-05-06T15:18:23Z")

</div>

Thanks so much for your prompt response. My error was caused by missing the import for Context which I solve by by adding `import org.openmrs.api.context.Context;` near the top of the class. Once again! am grateful for your response.

---

<div class="post-metadata">

**Author:** ![tendomart](https://talk.openmrs.org/user_avatar/talk.openmrs.org/tendomart/32/6753_2.png) [@tendomart](https://talk.openmrs.org/u/tendomart)\
**Post date:** [May 6, 2020, 3:21pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/7 "2020-05-06T15:21:21Z")

</div>

Glad you did. 😄 😄

---

<div class="post-metadata">

**Author:** ![herbert24](https://talk.openmrs.org/user_avatar/talk.openmrs.org/herbert24/32/8178_2.png) [@herbert24](https://talk.openmrs.org/u/herbert24)\
**Post date:** [May 6, 2020, 7:37pm UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/8 "2020-05-06T19:37:40Z")

</div>

just an add on,so many times when you are missing an import,you always get a red line around the code that requires the import.tested this with eclipse IDE

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 20, 2020, 10:52am UTC](https://talk.openmrs.org/t/error-cannot-find-symbol/28323/9 "2020-05-20T10:52:23Z")

</div>

Hello friends, can someone help me understand the abnormality of this unit test build failure. Am working on this [ticket](https://issues.openmrs.org/browse/TRUNK-4946) which has four classes and each needs a unit test. I had successfully created unit tests for the first three classes [BaseRetireHandler](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/handler/BaseRetireHandler.java), [BaseUnretireHandler](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/handler/BaseUnretireHandler.java) and [BaseVoidHandler](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/handler/BaseVoidHandler.java) but when I re-run `mvn package -Dtest=BaseVoidHandlerTest#handle_shoudNotUpdateFieldBesidesVoidFields ` to reconfirm if the test for [BaseVoidHandler](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/handler/BaseVoidHandler.java) class still works well, I got this error [https://pastebin.com/ivWhDZL1](https://pastebin.com/ivWhDZL1) which prompted me to re-test the [BaseUnretireHandler](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/handler/BaseUnretireHandler.java) and the output was the same error log as this [https://pastebin.com/ivWhDZL1](https://pastebin.com/ivWhDZL1). Today, without any changes made I attempted to test the [BaseVoidHandler](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/handler/BaseVoidHandler.java) class again and the build is successful as you can see on this link [https://pastebin.com/dVgQrMuv](https://pastebin.com/dVgQrMuv). I’m confused because I had spend two days searching for the solution to the error without any success but today without any changes made, its building. This is the link to my changes [https://github.com/openmrs/openmrs-core/compare/master...jwnasambu:TRUNK-4946?expand=1](https://github.com/openmrs/openmrs-core/compare/master...jwnasambu:TRUNK-4946?expand=1). Kindly what is the trick? am scared of spending more days on this now that am working on my final class.
