Openmrs not starting

I am unable to start OpenMRS this morning. Yesterday, it was functioning properly without any issues. I haven’t made any changes to the Java version or settings. However, it is currently displaying the following error. Could you please assist me in resolving this problem?

@abayomi Oh sorry! The error message you’re encountering indicates that there is a version mismatch between the Java Runtime Environment (JRE) you are using and the class file you’re trying to execute.

The error specifically states that the class file “org/openmrs/maven/plugins/Run” has been compiled using a newer version of Java (class file version 55.0) than the version of Java Runtime (JRE) you have installed, which only recognizes class file versions up to 52.0. Class file versions correspond to the version of the Java Development Kit (JDK) used to compile the code. To fix this error, kindly ensure you have the appropriate JDK installed and configured correctly

To amplify what @jwnasambu has said above, version 5.0.0 and above of the OpenMRS SDK requires a minimum of Java 11

For lower versions of Java, you can use lower versions of the OpenMRS SDK like below:

mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:4.6.0:setup

and

mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:4.6.0:run

Thanks for the reply. but I didn’t do changes to the java or any configurations.

Ok Thank You!

how do i stop the auto upgrade of sdk to 5.0.0

To prevent the automatic upgrade of the SDK to version 5.0.0, you can follow these general steps depending on your development environment:

  1. Package Manager (e.g., npm, pip):
  • If you are using a package manager like npm (for Node.js) or pip (for Python), you can specify the version of the SDK explicitly in your project’s package.json or requirements.txt file, respectively.
  • Open the package file and locate the entry for the SDK package.
  • Change the version number to the desired version (e.g., “4.0.0”) and save the file.
  • This will prevent the package manager from automatically upgrading the SDK to version 5.0.0.
  1. Build Tools (e.g., Gradle, Maven):
  • If you are using build tools like Gradle (for Android) or Maven (for Java), you can control the SDK version through the build configuration file.
  • Open the build.gradle (for Gradle) or pom.xml (for Maven) file of your project.
  • Locate the entry for the SDK dependency.
  • Specify the desired version number (e.g., “4.0.0”) in the configuration.
  • Save the file to ensure the build tool uses the specified version.
  1. Integrated Development Environment (IDE):
  • Some IDEs have settings to manage package or library upgrades.
  • Open your IDE and navigate to the project settings or preferences.
  • Look for options related to package management or SDKs.
  • Disable automatic updates or configure specific versions for the SDK you’re using.
  • Save the settings to ensure the IDE does not automatically upgrade the SDK.

Thanks @jwnasambu but I am just running servers on cmd, no pom files to fix version of sdk The scenario here is that openmrs-sdk always updates to the latest release version even without making any change to the mvn settings

Assume you are using the openmrs-sdk.properties file for configuration.

  1. Open the Command Prompt or terminal where you run your OpenMRS SDK commands.
  2. Navigate to the directory where the OpenMRS SDK is installed. This is usually the directory where the openmrs-sdk command is located.
  3. Look for a file named openmrs-sdk.properties in that directory. This file contains configuration settings for the SDK.
  4. Open the openmrs-sdk.properties file in a text editor.
  5. Look for a line that starts with sdk.download.latest=true or similar. This configuration allows the SDK to download the latest version automatically.
  6. Change the value to false, so it becomes sdk.download.latest=false.
  7. Save the openmrs-sdk.properties file and close the text editor.

Thanks @dkayiwa . I successfully ran Reference Application 2.11.0 and 2.12.2 with java 8 though 2.10.0 fails.

Have you tried taking your java version back to what you had using update-alternatives eg i Ubuntu **@  ~  sudo update-alternatives --config java [sudo] password for *****: There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status

0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode

  • 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode

Press to keep the current choice[*], or type selection number:

FWIW, yesterday, we made a release of the OpenMRS SDK which should let you use Java 8 as before.