Facing Errors While Running OpenMRS API Locally, WebServices.rest Issue

I followed the official OpenMRS documentation and successfully set up OpenMRS core along with the database on my local machine. The OpenMRS core is running without any issues, and the database connection is working as expected.

However, when I attempt to run the webservices.rest API, I encounter errors. I’ve gone through the setup multiple times and tried various troubleshooting steps, but the issue persists.

Steps Taken:

  1. Installed OpenMRS core and connected it to my local database.
  2. Followed all the necessary steps for setting up webservices.rest API.
  3. The OpenMRS core runs successfully.
  4. I encounter errors specifically when trying to access the web services.

Error Details:

-- surefire:2.22.1:test (default-test) @ webservices.rest-omod-common ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest
[ERROR] Tests run: 53, Failures: 0, Errors: 39, Skipped: 0, Time elapsed: 0.538 s <<< FAILURE! - in org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest
[ERROR] getResourceByName_shouldReturnResourceForGivenNameAndIgnoreUnannotatedResources(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0.351 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceByName_shouldReturnResourceForGivenNameAndIgnoreUnannotatedResources(RestServiceImplTest.java:208)

[ERROR] getResourceBySupportedClass_shouldReturnResourceSupportingGivenClassAndCurrentOpenmrsVersion(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceBySupportedClass_shouldReturnResourceSupportingGivenClassAndCurrentOpenmrsVersion(RestServiceImplTest.java:367)

[ERROR] initialize_shouldClearCachedResourcesAndSearchHandlersAndReinitializeThem(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.initialize_shouldClearCachedResourcesAndSearchHandlersAndReinitializeThem(RestServiceImplTest.java:1137)

[ERROR] getResourceByName_shouldReturnResourceForGivenName(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0.016 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceByName_shouldReturnResourceForGivenName(RestServiceImplTest.java:190)

[ERROR] getSearchHandler_shouldReturnNullIfParametersDoNotContainASearchHandlerIdAndNoOtherNonSpecialRequestParameters(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandler_shouldReturnNullIfParametersDoNotContainASearchHandlerIdAndNoOtherNonSpecialRequestParameters(RestServiceImplTest.java:618)

[ERROR] getSearchHandlers_shouldReturnNullIfNoSearchHandlerIsFoundForGivenResourceName(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandlers_shouldReturnNullIfNoSearchHandlerIsFoundForGivenResourceName(RestServiceImplTest.java:1023)

[ERROR] getResourceByName_shouldFailIfResourceForGivenNameDoesNotSupportTheCurrentOpenmrsVersion(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceByName_shouldFailIfResourceForGivenNameDoesNotSupportTheCurrentOpenmrsVersion(RestServiceImplTest.java:271)

[ERROR] getSearchHandler_shouldReturnSearchHandlerProvidingAllRequestParametersAndParametersSatisfyingItsRequiredParameters(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandler_shouldReturnSearchHandlerProvidingAllRequestParametersAndParametersSatisfyingItsRequiredParameters(RestServiceImplTest.java:648)

[ERROR] getSearchHandler_shouldReturnNullIfGivenParametersAreMissingAParameterRequiredBySearchHandlersEligibleForGivenResourceNameAndParameters(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandler_shouldReturnNullIfGivenParametersAreMissingAParameterRequiredBySearchHandlersEligibleForGivenResourceNameAndParameters(RestServiceImplTest.java:680)

[ERROR] getResourceBySupportedClass_shouldReturnResourceWithLowerOrderValueIfTwoResourcesWithTheSameNameAreFoundForGivenClass(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceBySupportedClass_shouldReturnResourceWithLowerOrderValueIfTwoResourcesWithTheSameNameAreFoundForGivenClass(RestServiceImplTest.java:521)

[ERROR] getResourceByName_shouldReturnResourceWithLowerOrderValueIfTwoResourcesWithTheSameNameAreFoundForGivenName(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0.015 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceByName_shouldReturnResourceWithLowerOrderValueIfTwoResourcesWithTheSameNameAreFoundForGivenName(RestServiceImplTest.java:350)

[ERROR] getSearchHandlers_shouldFailIfTwoSearchHandlersForTheSameResourceHaveTheSameId(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandlers_shouldFailIfTwoSearchHandlersForTheSameResourceHaveTheSameId(RestServiceImplTest.java:1080)

[ERROR] getSearchHandler_shouldReturnDefaultSearchHandlerIfDefaultAndCustomSearchHandlersMatchGivenResourceAndParametersAndNoSearchHandlerIdIsSpecified(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandler_shouldReturnDefaultSearchHandlerIfDefaultAndCustomSearchHandlersMatchGivenResourceAndParametersAndNoSearchHandlerIdIsSpecified(RestServiceImplTest.java:711)

[ERROR] getResourceBySupportedClass_shouldFailIfNoResourceSupportingGivenClassAndCurrentOpenmrsVersionWasFound(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceBySupportedClass_shouldFailIfNoResourceSupportingGivenClassAndCurrentOpenmrsVersionWasFound(RestServiceImplTest.java:385)

[ERROR] getResourceHandlers_shouldReturnListWithDelegatingResourceWithLowerOrderValueIfTwoResourcesWithTheSameNameAreFoundForGivenName(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceHandlers_shouldReturnListWithDelegatingResourceWithLowerOrderValueIfTwoResourcesWithTheSameNameAreFoundForGivenName(RestServiceImplTest.java:876)

[ERROR] getResourceBySupportedClass_shouldFailIfTwoResourcesWithSameNameAndOrderAreFoundForGivenClass(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceBySupportedClass_shouldFailIfTwoResourcesWithSameNameAndOrderAreFoundForGivenClass(RestServiceImplTest.java:500)

[ERROR] getSearchHandlers_shouldReturnNullIfNoSearchHandlerIsFoundForCurrentOpenmrsVersion(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandlers_shouldReturnNullIfNoSearchHandlerIsFoundForCurrentOpenmrsVersion(RestServiceImplTest.java:1044)

[ERROR] getResourceHandlers_shouldReturnListOfDelegatingResourceHandlersIncludingSubclassHandlers(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0.016 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceHandlers_shouldReturnListOfDelegatingResourceHandlersIncludingSubclassHandlers(RestServiceImplTest.java:850)

[ERROR] getResourceBySupportedClass_shouldReturnResourceSupportingDirectSuperclassOfGivenClassIfNoResourceSupportingGivenClassWasFoundButMultipleResourcesSupportingMultipleSuperclassesExist(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceBySupportedClass_shouldReturnResourceSupportingDirectSuperclassOfGivenClassIfNoResourceSupportingGivenClassWasFoundButMultipleResourcesSupportingMultipleSuperclassesExist(RestServiceImplTest.java:465)

[ERROR] getResourceBySupportedClass_shouldReturnResourceSupportingSuperclassOfGivenClassIfGivenClassIsAHibernateProxy(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceBySupportedClass_shouldReturnResourceSupportingSuperclassOfGivenClassIfGivenClassIsAHibernateProxy(RestServiceImplTest.java:425)

[ERROR] getAllSearchHandlers_shouldReturnAllSearchHandlersIfSearchHandlersHaveBeenInitialized(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getAllSearchHandlers_shouldReturnAllSearchHandlersIfSearchHandlersHaveBeenInitialized(RestServiceImplTest.java:945)

[ERROR] getResourceBySupportedClass_shouldReturnResourceSupportingSuperclassOfGivenClassIfNoResourceSupportingGivenClassWasFound(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceBySupportedClass_shouldReturnResourceSupportingSuperclassOfGivenClassIfNoResourceSupportingGivenClassWasFound(RestServiceImplTest.java:444)

[ERROR] initialize_shouldFailIfTwoSearchHandlersForTheSameResourceHaveTheSameId(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.initialize_shouldFailIfTwoSearchHandlersForTheSameResourceHaveTheSameId(RestServiceImplTest.java:1234)

[ERROR] initialize_shouldFailIfTwoResourcesWithSameNameAndOrderAreFound(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.initialize_shouldFailIfTwoResourcesWithSameNameAndOrderAreFound(RestServiceImplTest.java:1210)

[ERROR] getSearchHandler_shouldReturnNullIfNoSearchHandlerIsFoundForGivenResourceName(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandler_shouldReturnNullIfNoSearchHandlerIsFoundForGivenResourceName(RestServiceImplTest.java:796)

[ERROR] getSearchHandler_shouldReturnNullIfANonSpecialRequestParameterInGivenParametersCannotBeFoundInAnySearchHandler(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandler_shouldReturnNullIfANonSpecialRequestParameterInGivenParametersCannotBeFoundInAnySearchHandler(RestServiceImplTest.java:772)

[ERROR] getSearchHandler_shouldFailIfTwoSearchHandlersMatchGivenResourceAndParametersAndNoSearchHandlerIdIsSpecified(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandler_shouldFailIfTwoSearchHandlersMatchGivenResourceAndParametersAndNoSearchHandlerIdIsSpecified(RestServiceImplTest.java:738)

[ERROR] getResourceByName_shouldFailIfSubresourceForGivenNameDoesNotSupportTheCurrentOpenmrsVersion(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceByName_shouldFailIfSubresourceForGivenNameDoesNotSupportTheCurrentOpenmrsVersion(RestServiceImplTest.java:310)

[ERROR] getResourceBySupportedClass_shouldFailIfNoResourceSupportingGivenClassWasFound(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceBySupportedClass_shouldFailIfNoResourceSupportingGivenClassWasFound(RestServiceImplTest.java:404)

[ERROR] getResourceByName_shouldReturnSubresourceForGivenName(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getResourceByName_shouldReturnSubresourceForGivenName(RestServiceImplTest.java:291)

[ERROR] getSearchHandler_shouldFailIfTwoSearchHandlersForTheSameResourceHaveTheSameId(org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest)  Time elapsed: 0.016 s  <<< ERROR!
java.lang.IllegalAccessException: Can not set static final java.lang.String field org.openmrs.util.OpenmrsConstants.OPENMRS_VERSION_SHORT to java.lang.String
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.setCurrentOpenmrsVersion(RestServiceImplTest.java:227)
        at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImplTest.getSearchHandler_shouldFailIfTwoSearchHandlersForTheSameResourceHaveTheSameId(RestServiceImplTest.java:588)

[ERROR] getRepresentation_shouldGetDefaultRepresentationWhenSpecified(org.openmrs.module.webservices.rest.web.api.RestServiceTest)  Time elapsed: 24.194 s  <<< ERROR!
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

[ERROR] getRepresentation_shouldGetANamedRepresentationWhenSpecified(org.openmrs.module.webservices.rest.web.api.RestServiceTest)  Time elapsed: 48.199 s  <<< ERROR!
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

[ERROR] getRepresentation_shouldGetANamedRepresentationWhenSpecified(org.openmrs.module.webservices.rest.web.api.RestServiceTest)  Time elapsed: 48.199 s  <<< ERROR!
java.lang.NullPointerException

[ERROR] getRepresentation_shouldGetANamedRepresentationWhenSpecified(org.openmrs.module.webservices.rest.web.api.RestServiceTest)  Time elapsed: 48.199 s  <<< ERROR!
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

[ERROR] getRepresentation_shouldGetRefRepresentationWhenSpecified(org.openmrs.module.webservices.rest.web.api.RestServiceTest)  Time elapsed: 48.219 s  <<< ERROR!
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

[ERROR] getRepresentation_shouldGetRefRepresentationWhenSpecified(org.openmrs.module.webservices.rest.web.api.RestServiceTest)  Time elapsed: 48.219 s  <<< ERROR!
java.lang.NullPointerException

[ERROR] getRepresentation_shouldGetRefRepresentationWhenSpecified(org.openmrs.module.webservices.rest.web.api.RestServiceTest)  Time elapsed: 48.219 s  <<< ERROR!
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

What I Need Help With:

Could someone help me identify and resolve the error related to webservices.rest? I would appreciate guidance on fixing this issue and ensuring the API runs smoothly.


Hi @bhabha, welcome!

Which java version are you building the module with?

1 Like

Sorry for late reply, Now project is running but show this error The logs show repeated connection failures while trying to reach the server:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.openmrs.module.webservices.rest.SessionIT
Waiting for server at http://localhost:8080/openmrs for 300 more seconds...
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Waiting for 295 more seconds...
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Waiting for 280 more seconds...
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Waiting for 266 more seconds...
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Waiting for 252 more seconds...
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Waiting for 238 more seconds...
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Waiting for 224 more seconds...

Update your module and compile again.

Could you please let me know which module you’re talking and how I can update mine?

The one you are getting problems with.