Advance

Troubleshooting Tomcat Errors on Ubuntu 22.04

Troubleshooting Tomcat Errors on Ubuntu 22.04

Apache Tomcat is an open-source web server and servlet container that allows Java applications to run on a server. However, like any software, it can encounter errors or issues during installation or operation. In this article, we will explore some common Tomcat errors and their troubleshooting steps specifically tailored for Ubuntu 22.04. If you’re considering purchasing an Ubuntu VPS server, be sure to take a look at the packages available on the Eldernode website.

Recommended Article: How to Repair Databases in MySQL

Troubleshoot Tomcat Errors on Ubuntu 22.04

When troubleshooting Tomcat, the first step is to examine the Tomcat logs. You can use these logs at C:\Program Files\Apache Software Foundation\Tomcat 6.0\logs. Look for the file named stdout_yyyymmdd.txt, where yyyymmdd corresponds to the current date. If the log file is too lengthy and it’s challenging to locate the relevant information, you can stop the Tomcat service, rename the file to stdout_yyyymmdd_old.txt, and restart Tomcat. To stop the Tomcat Service on Windows, go to the control panel, then administrative tools, and select services. Doing so will initiate the creation of a new log file named stdout_yyyymmdd.txt.

If you are experiencing sluggish performance, it is important to verify that you have installed Tomcat from the official website, tomcat.apache.org. Installing Tomcat through the “apt-get install” command in Ubuntu, specifically the tomcat6 package, may lead to unfavorable performance issues. To ensure optimal performance, it is recommended to obtain the Tomcat installation directly from the official Apache Tomcat website.

Error1: Permission Issues When Running Tomcat as a Service

When attempting to run Tomcat as a service on Ubuntu, you may encounter permission problems as shown below:

java.security.AccessControlException: access denied (java.io.FilePermission /usr/share/tomcat6/webapps/openmrs/WEB-INF/dwr-modules.xml delete)

A convenient solution to overcome this obstacle involves disabling the Java security manager within the /etc/init.d/tomcat6 file. So open the /etc/init.d/tomcat6  file with your desired text editor and edit the following configuration:

Use the Java security manager? (yes/no)  TOMCAT6_SECURITY=no

By implementing this approach, you can streamline the process and eliminate the associated permission-related challenges. This modification will provide a smoother experience in running Tomcat on your Ubuntu system.

Error 2: Tomcat service Cannot Start

If you encounter difficulties initiating the Tomcat service, consider examining the Tomcat logs located at C:/Program Files/Apache Software Foundation/Tomcat/logs. Should these logs contain errors such as “Failed creating java C:\Program Files\Java\jre1.6.0\bin\client\jvm.dll,” please follow the steps outlined below:

– Conduct a search for msvcr71.dll on your hard drive

– Copy the located file to C:\Windows\System32

Error 3: Tomcat Hangs and Stops Responding

When attempting to upload the war file, Tomcat becomes unresponsive and stops functioning. This issue usually arises when you haven’t specified a MySQL user account for OpenMRS to utilize when accessing the database, or if you haven’t granted this user complete access to the OpenMRS database.

The default credentials for accessing the system are configured with the username “test” and password “test.” Nevertheless, you have the flexibility to override these default values by modifying the openmrs_runtime_properties.properties configuration file to set your desired username and password combination.

In order to resolve this issue, it is recommended to use Navicat or the MySQL administration tool (which is available from MySQL) to verify the existence of a user account with the username “test” and password “test.” Additionally, ensure that this user account has been granted comprehensive access privileges to the OpenMRS database.

Error 4: Cannot Connect to Tomcat on Port 8080

Port 8080 is occasionally occupied by other programs like Popfile and TivoServer. To check if another process is currently utilizing port 8080, you can execute the following command in Windows:

netstat -ao

You will receive the required information with this command.

Error 5: Out Of Memory Error

The error occurs when Tomcat reaches its memory limit, resulting in the depletion of available resources. This situation is often triggered by excessive usage of the “Update” or “Reload” function on a web application. Unfortunately, Tomcat and/or the JVM currently exhibit inadequate memory release when a web application is destroyed and recreated. As a consequence, after numerous reloads, Tomcat exhausts its allocated memory, leading to system freeze or unresponsiveness.

Error 6: Can’t Deploy Applications

This solution assumes that you are using a Linux machine. If you are working on a different operating system, such as Windows, you will need to adjust the steps accordingly. Firstly, access the Tomcat web interface and undeploy the application. Afterward, log in to the command line interface of your server as the root user and proceed to identify the process ID by using the following command:

ps ax | grep tomcat

The process ID you are looking for will likely be the first item in the output, and you can identify it by its length of about three or four lines. Locate the process ID by identifying the first number on that line, and kill it using the following command:

kill -9 processid

And then restart the service using the command below:

service tomcat6 start

Once you have completed the previous steps, log back into the Tomcat web interface and proceed to deploy your application.

Error 7: Lost Tomcat Password

The Tomcat admin password can be obtained by accessing the file tomcat-users.xml, which is located in the following directory:

 C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\tomcat-users.xml

Error 8: The openmrs.war Fails to Start

After deploying the openmrs.war file, the startup process may encounter an issue and fails to initiate. The only hints available to diagnose the problem are two brief messages found in the Tomcat log file:

SEVERE: Error listenerStart  SEVERE: Context [/openmrs] startup failed due to previous errors

The most probable issue lies with the application_data_directory. Please verify if you have created the runtime properties file and ensure that you have correctly specified the application_data_directory within the runtime properties. Additionally, check if the directory actually exists and confirm whether Tomcat has the required read/write permissions on it. Once you have confirmed that all these conditions are met, it is advisable to investigate further for any potential security breaches within your Tomcat configuration.

Error 9: Error Loading Persisted Sessions

Tomcat attempts to restore the precise memory state after each restart. However, OpenMRS does not rely on this functionality, so you can disregard the bothersome warnings that are displayed in the logs, resembling the following format:

SEVERE: An IOException occurred while loading the persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException

To deactivate session persistence, locate the “tomcathome/conf/server.xml” file and remove the comment tags surrounding the line “<Manager pathname=”” />”.

Error 10: ElException in parsing some JSP pages

An issue arises when parsing certain JSP pages (observed in updated Tomcat 7 and potentially other servlet containers conforming to EL Spec 2.2). The latest version of EL Spec v2.2 prohibits the usage of Java identifiers and reserved keywords in EL expressions. However, in OpenMRS, there are JSP sections that do not comply with this new specification. To address this problem, a workaround is available by adding the following line to the CATALINA_OPTS environment variable:

-Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true

That’s it!

Recommended Article: How to Find Out Which Process Listening On A Particular Port

Conclusion

Troubleshooting Tomcat errors on Ubuntu 22.04 requires a systematic approach to identify and resolve underlying issues. By following the steps mentioned in this article, you should be able to fix Tomcat errors on Ubuntu 22.04.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day