Tomcat service active but exited - java

When I started tomcat on linux server,approximately after a day,tomcat shutdown and it shows status like active(exited).Can u help me pls?
I have already log :
tomcat8.service - LSB: Start Tomcat.
Loaded: loaded (/etc/init.d/tomcat8; bad; vendor preset: enabled)
Active: active (exited) since Sat 2017-06-10 12:23:52 UTC; 1 day 18h ago
Docs: man:systemd-sysv-generator(8)
Jun 10 12:23:47 ip-172-31-7-212 systemd[1]: Stopped LSB: Start Tomcat..
Jun 10 12:23:47 ip-172-31-7-212 systemd[1]: Starting LSB: Start Tomcat....
Jun 10 12:23:47 ip-172-31-7-212 tomcat8[22872]: * Starting Tomcat servlet engine tomcat8
Jun 10 12:23:52 ip-172-31-7-212 tomcat8[22872]: ...done.
Jun 10 12:23:52 ip-172-31-7-212 systemd[1]: Started LSB: Start Tomcat..
ubuntu#ip-172-31-7-212:~$

My experience with slightly older versions of Tomcat would lead me to believe there could be a memory leak with the application. At least as recently as Tomcat 6, we would have issues where the server would run out of memory and would not report anything of the sort. It would stay active, but stop processing requests.
You should try to profile the memory usage of your application to see if it grows over time. If this is a production system, institute scheduled restarts in the meantime while the memory leak is being debugged.

Related

How to start a java springboot application as a sytem service in linux

I am trying to create a systemd service for a spring boot application, servie is creating but the status shows as follows,
● vehicle_service-0.1.0.service - vehicle micro service
Loaded: loaded (/etc/systemd/system/vehicle_service-0.1.0.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2022-09-19 05:30:50 UTC; 10s ago
Process: 23815 ExecStart=/home/Manoj/vehicle-servive/build/libs/start.sh (code=exited, status=203/EXEC)
Main PID: 23815 (code=exited, status=203/EXEC)
Sep 19 05:30:50 jenkins systemd[1]: Unit vehicle_service-0.1.0.service entered failed state.
Sep 19 05:30:50 jenkins systemd[1]: vehicle_service-0.1.0.service failed.
I suggest you use docker-compose
because when a docker container is up if you reboot system it is still up
try add #!/bin/sh this to the top of the script
/home/Manoj/vehicle-servive/build/libs/start.sh

java.lang.IllegalStateException: Can't move to started state when closed while starting elasticsearch

I am trying to add cluster configuration to my elasticsearch using a bash script. I get below error while restarting the elasticsearch.
Below is the output of journalctl -xe
Feb 28 21:22:06 elk-1 systemd[1]: Starting Elasticsearch...
-- Subject: Unit elasticsearch.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit elasticsearch.service has begun starting up.
Feb 28 21:23:25 elk-1 systemd[1]: Failed to start Elasticsearch.
-- Subject: Unit elasticsearch.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit elasticsearch.service has failed.
--
-- The result is failed.
Feb 28 21:23:25 elk-1 systemd[1]: Unit elasticsearch.service entered failed state.
Feb 28 21:23:25 elk-1 systemd[1]: elasticsearch.service failed.
Feb 28 21:23:25 elk-1 polkitd[1780]: Unregistered Authentication Agent for unix-process:25463:654715126 (system bus name :1.1315013, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
And this is what i found in elasticsearch.log
uncaught exception in thread [main]
java.lang.IllegalStateException: Can't move to started state when closed
at org.elasticsearch.common.component.Lifecycle.canMoveToStarted(Lifecycle.java:109)
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:42)
at org.elasticsearch.node.Node.start(Node.java:1181)
at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:335)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:443)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:166)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:157)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
at org.elasticsearch.cli.Command.main(Command.java:77)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:122)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
I am unable to understand the actual issue causing this as the service got restarted after a couple of retries using systemctl stop/start elasticsearch.
Help please :)

Jetty 5.1.x start after 10 minutes or after "real local connexion"

I work on a very old system : OSGi Framework with Jetty.
Java command is launch inside a screen with -DmS parameters.
At the end, console give me this :
osgi> Sep 14, 2021 9:17:43 AM org.mortbay.http.HttpServer doStart
INFO: Version Jetty/5.1.x
Sep 14, 2021 9:28:32 AM org.mortbay.util.Container start
INFO: Started org.eclipse.equinox.http.jetty.internal.Servlet25Handler#90832e
Sep 14, 2021 9:28:32 AM org.mortbay.util.Container start
INFO: Started HttpContext[/,/]
Sep 14, 2021 9:28:32 AM org.mortbay.util.FileResource <clinit>
INFO: Checking Resource aliases
Sep 14, 2021 9:28:33 AM org.mortbay.http.SocketListener start
INFO: Started SocketListener on 0.0.0.0:[port]
Sep 14, 2021 9:28:33 AM org.mortbay.util.Container start
INFO: Started org.mortbay.http.HttpServer#142bece
Experimental: JNI_OnLoad called.
And :
ss
Framework is launched.
id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.2.R34x_v20080826-1230
1 ACTIVE javax.servlet_2.4.0.v200806031604
2 ACTIVE org.apache.commons.logging_1.1.1.v20080605-1935
3 ACTIVE org.eclipse.equinox.http.jetty_1.1.0.v20080425
4 ACTIVE org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830
5 ACTIVE org.eclipse.osgi.services_3.1.200.v20071203
6 ACTIVE org.mortbay.jetty_5.1.14.v200806031611
7 ACTIVE org.apache.log4j_1.2.13.v200806030600
Fragments=14
8 ACTIVE Jamod_0.0.0
9 ACTIVE org.openscada.opc.dcom_0.5.0
10 ACTIVE Comm Linux RXTX Bundle_0.0.0
11 ACTIVE org.apache.commons.io_1.4.0
12 ACTIVE org.apache.commons.fileupload_1.2.1
13 ACTIVE org.apache.commons.lang3_3.1.0
14 RESOLVED InterpreterLog4JProperties_0.0.0
Master=7
15 ACTIVE EmailManager_1.0.0
16 ACTIVE Interpreter_1.0.0
17 ACTIVE InterpreterServlet_1.0.0
But during 10 minutes, I have only this :
osgi> Sep 14, 2021 10:16:06 AM org.mortbay.http.HttpServer doStart
INFO: Version Jetty/5.1.x
ss
Framework is launched.
id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.2.R34x_v20080826-1230
1 ACTIVE javax.servlet_2.4.0.v200806031604
2 ACTIVE org.apache.commons.logging_1.1.1.v20080605-1935
3 STARTING org.eclipse.equinox.http.jetty_1.1.0.v20080425
4 RESOLVED org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830
5 RESOLVED org.eclipse.osgi.services_3.1.200.v20071203
6 RESOLVED org.mortbay.jetty_5.1.14.v200806031611
7 RESOLVED org.apache.log4j_1.2.13.v200806030600
Fragments=14
8 RESOLVED Jamod_0.0.0
9 RESOLVED org.openscada.opc.dcom_0.5.0
10 RESOLVED Comm Linux RXTX Bundle_0.0.0
11 RESOLVED org.apache.commons.io_1.4.0
12 RESOLVED org.apache.commons.fileupload_1.2.1
13 RESOLVED org.apache.commons.lang3_3.1.0
14 RESOLVED InterpreterLog4JProperties_0.0.0
Master=7
15 RESOLVED EmailManager_1.0.0
16 RESOLVED Interpreter_1.0.0
17 RESOLVED InterpreterServlet_1.0.0
I don't want to modify java code (too old, too long), I just want to start it correctly...
Finally someone have notice that if I plug a screen and a keyboard on this server, and log in, jetty start at once ?
(Whereas this doesn't work with ssh log in...?)
I think in my case, the simplest way (not perfect and clean I agree), would be to simulate a "real log in" (but I don't understand what is the difference between "real/local" log in and ssh log in).
Jetty 5.1.14 was EOL (End of Life) back in the year 2009 - https://www.eclipse.org/jetty/download.php#version-table
There has literally been over 1 million commits on Jetty over the past 12 years (I just checked)
For success with this old of a version of Jetty ...
You MUST run it with Java 1.4 (ONLY) and nothing newer. Newer JVMs have various things disabled that Jetty of that era require to run. (You could eke out Java 1.5, but only if you have SSL/TLS disabled, and don't use that specific version of OSGi, which only supported Java 1.2)
You MUST run it on an OS that wasn't upgraded in the past 12 years. Newer OSs have updated to support the feature-set of newer JVMs and dropped support for the quirks of older JVMs and will not run older JVMs reliably.
You MUST NOT use SSL (it's impossible for you to use it now). SSL/TLS has evolved extremely rapidly since 2009, and you have a featureset in the Java 1.4 JVM that is 100% not supported on modern web browsers. This means even if you turned it on, your modern browser has a minimum TLS 1.2 and a Cipher Suite that Java 1.4 doesn't even support on it's high end / non-export configurations.
So in short, you cannot upgrade Jetty (your choice), so you cannot upgrade the JVM (consequence of your first choice), and you cannot upgrade the OS (if you expect to run Java 1.4) for success.
If you have upgraded your JVM or your OS you have basically screwed yourself. I cannot even find a docker image with that old of a OS or JVM for you to limp along with.

Tomcat is runing, but cannot access it remotely

Run Tomcat8 in centos7, Checked the tomcat status get following information:
[root#**** conf]# systemctl status tomcat
● tomcat.service - Apache Tomcat 8 Servlet Container
Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2017-11-10 09:39:22 EST; 37min ago
Process: 1013 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 1102 (java)
CGroup: /system.slice/tomcat.service
└─1102 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=o...
Nov 10 09:39:22 ****** systemd[1]: Starting Apache Tomcat 8 Servlet Container...
Nov 10 09:39:22 ****** systemd[1]: Started Apache Tomcat 8 Servle
But when check the homepage of tomcat (http://..***:8080), in Chrome,
Get the following information:
This page isn’t working
***.**.***.** didn’t send any data. ERR_EMPTY_RESPONSE
The centos 7 is with firewall and it running.
Thanks,
-Jimmy

Can not start elasticsearch as a service in ubuntu 16.04

I have recently upgraded my machine from Ubuntu 14.04 to 16.04. I am facing problem of using the elasticsearch as a service. I installed elasticsearch using:
sudo apt-get install elasticsearch
Now sudo service elasticsearch status command shows me this result:
elasticsearch.service - LSB: Starts elasticsearch
Loaded: loaded (/etc/init.d/elasticsearch; bad; vendor preset: enabled)
Active: active (exited) since Sat 2016-07-30 18:28:13 BDT; 1h 19min ago
Docs: man:systemd-sysv-generator(8)
Main PID: 7988 (code=exited, status=1/FAILURE)
CGroup: /system.slice/elasticsearch.service
Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found
Jul 30 18:28:13 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 18:28:46 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 18:35:30 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 19:04:36 dimik systemd[1]: Started A search engine.
Jul 30 19:07:48 dimik systemd[1]: Started A search engine.
Jul 30 19:27:01 dimik systemd[1]: Started A search engine.
Jul 30 19:27:51 dimik systemd[1]: Started A search engine.
Jul 30 19:28:54 dimik systemd[1]: Started A search engine.
Jul 30 19:29:18 dimik systemd[1]: Started LSB: Starts elasticsearch.
Although Java is installed in my machine and I can start the server using this command.
sudo /usr/share/elasticsearch/bin/elasticsearch
I am kind of stuck here. Any help will be appreciated.
Edit
After setting up JAVA_HOME for root the error:
elasticsearch.service - LSB: Starts elasticsearch
Loaded: loaded (/etc/init.d/elasticsearch; bad; vendor preset: enabled)
Active: active (exited) since Sat 2016-07-30 18:28:13 BDT; 3h 32min ago
Docs: man:systemd-sysv-generator(8)
Main PID: 7988 (code=exited, status=1/FAILURE)
CGroup: /system.slice/elasticsearch.service
Jul 30 18:35:30 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 19:04:36 dimik systemd[1]: Started A search engine.
Jul 30 19:07:48 dimik systemd[1]: Started A search engine.
Jul 30 19:27:01 dimik systemd[1]: Started A search engine.
Jul 30 19:27:51 dimik systemd[1]: Started A search engine.
Jul 30 19:28:54 dimik systemd[1]: Started A search engine.
Jul 30 19:29:18 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 20:02:07 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 20:20:21 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 21:59:21 dimik systemd[1]: Started LSB: Starts elasticsearch.
I found the solution for this issue. The solution comes from this discussion thread- Can’t start elasticsearch with Ubuntu 16.04 on elastic's website.
It seems that to get Elasticsearch to run on 16.04 you have to set START_DAEMON to true on /etc/default/elasticsearch. It comes commented out by default, and uncommenting it makes Elasticsearch start again just fine.
Be sure to use systemctl restart instead of just start because the
service is started right after installation, and apparently there's
some socket/pidfile/something that systemd keeps that must be released
before being able to start the service again.
The problem lies on log files, "No java runtime was found."
Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found
Here's my solution to the problem.
Check elasticsearch init file
sudo nano /etc/init.d/elasticsearch
search for
. /usr/share/java-wrappers/java-wrappers.sh
find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default
export JAVA_HOME
Check java-wrappers.sh file
sudo nano /usr/share/java-wrappers/java-wrappers.sh
Now you could see the warning comes from
#Displays a warning
java_warning() {
echo "[warning] $0: $#" >&2;
}
Somehow, java directories are not listed in jvm-list.sh files
Now edit the jvm-list.sh file
sudo nano /usr/lib/java-wrappers/jvm-list.sh
Edit the line add your java directories files, in my case add /usr/lib/jvm/java-8-oracle*
__jvm_oracle8="/usr/lib/jvm/jdk-8-oracle-* /usr/lib/jvm/jre-8-oracle-* /usr/lib/jvm/java-8-oracle*"
Now restart the service and check elasticsearch services
sudo systemctl restart elasticsearch
sudo systemctl elasticsearch status
curl -X GET "http://localhost:9200"
Hopes this would help
My problem was different, I started elasticsearch manually as root user, so some files were created with wrong ownership, so elasticsearch user cannot write on them.
You can try to start elasticsearch from console to see errors:
sudo -u elasticsearch /usr/share/elasticsearch/bin/elasticsearch \
-Des.default.config=/etc/elasticsearch/elasticsearch.yml \
-Des.default.path.home=/usr/share/elasticsearch \
-Des.default.path.logs=/var/log/elasticsearch \
-Des.default.path.data=/var/lib/elasticsearch \
-Des.default.path.work=/tmp/elasticsearch \
-Des.default.path.conf=/etc/elasticsearch
To fix on my machine I had to do:
rm -rf /var/log/elasticsearch/*
rm -rf /var/lib/elasticsearch/*
Open /etc/init.d/elasticsearch file in editor, Comment below lines
. /usr/share/java-wrappers/java-wrappers.sh
find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default
Set JAVA_HOME manually like so:
export JAVA_HOME="/usr"
service elasticsearch start
Remove unnecessary java packages using
sudo apt autoremove
Then install elasticsearch again and start it as
sudo apt install elasticsearch
service elasticsearch status
Have you enabled the service ?
systemctl enable elasticsearch

Categories