Tomcat is runing, but cannot access it remotely - java

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

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

Unable to configure ActiveMQ web console in Ubuntu 18.x

I followed this tutorial https://howtoprogram.xyz/2017/08/09/how-to-install-activemq-on-ubuntu-16-04-lts-xenial-xerus/ to install ActiveMQ manually and everything worked fine and i was even able to access the webhost on http://127.0.0.1:8161. But I tried the sudo apt-get install automatic option out of curiosity and though it was also successful, I cannot access the web console for both installations now though I am able to start them. Below are snippets of the output:
● activemq.service - LSB: ActiveMQ instance
Loaded: loaded (/etc/init.d/activemq; generated)
Active: active (running) since Thu 2019-03-28 22:52:17 GMT; 3s ago
Docs: man:systemd-sysv-generator(8)
Process: 14696 ExecStop=/etc/init.d/activemq stop (code=exited, status=0/SUCCE
Process: 15233 ExecStart=/etc/init.d/activemq start (code=exited, status=0/SUC
Tasks: 31 (limit: 4915)
CGroup: /system.slice/activemq.service
└─15265 /usr/lib/jvm/default-java//bin/java -Xms512M -Xmx512M -Dorg.a
Mar 28 22:52:11 sys-abj systemd[1]: Starting LSB: ActiveMQ instance...
Mar 28 22:52:11 sys-abj activemq[15233]: * Starting ActiveMQ instance activemq
Mar 28 22:52:17 sys-abj activemq[15233]: ...done.
Mar 28 22:52:17 sys-abj systemd[1]: Started LSB: ActiveMQ instance.
and a netstat to the transportConnector tells it's listening by yielding this result:
tcp6 0 0 127.0.0.1:61616 :::* LISTEN 15265/java
However, any time I point to 127.0.0.1:8161, I get no feed back.
I stumbled upon this How to install or config activemq admin cosole(jetty) use apt-get command? link but I still can't wrap my head around how to configure the web console.
Any help would be much appreciated
I have been able to fix it!
I deleted ActiveMQ and its accompanying dependencies by running sudo apt-get remove --auto-remove activemq, downloaded the zip file again from https://activemq.apache.org/download.html and unzipped it to my preferred destination.
I wouldn't recommend anyone running the sudo apt-get install activemq command if you're not sure of what you're doing

Tomcat service active but exited

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.

Glassfish fails to restart from web portail but works with asadmin command

With the systemctl command systemctl restart glassfish, GF restarts properly.
But when I try to restart via the Web portail https://127.0.0.1:4848 => server => Restart, it fails without any reason.
Glassfish stops but never restarts.
I'm using Glassfish 3.1.2.2 on Fedora 20 with java 1.6.0_45 x86_64.
(I've also tried with GF 4.1 on Centos 7 with java 1.8.0_66 x86_64 with the same result)
Here is my glassfish.service file:
[Unit]
Description=GlassFish Server
[Service]
User=glassfish
ExecStart=/usr/share/glassfish3/glassfish/bin/asadmin start-domain
ExecStop=/usr/share/glassfish3/glassfish/bin/asadmin stop-domain
ExecReload=/usr/share/glassfish3/glassfish/bin/asadmin restart-domain
Type=forking
[Install]
WantedBy=multi-user.target
Here is the service status systemctl status glassfish -l:
glassfish.service - GlassFish Server
Loaded: loaded (/usr/lib/systemd/system/glassfish.service; enabled)
Active: failed (Result: exit-code) since Wed 2016-07-27 11:17:22 CEST; 52s ago
Process: 9366 ExecStop=/usr/share/glassfish3/glassfish/bin/asadmin stop-domain (code=exited, status=0/SUCCESS)
Process: 877 ExecStart=/usr/share/glassfish3/glassfish/bin/asadmin start-domain (code=exited, status=0/SUCCESS)
Main PID: 1420 (code=exited, status=10)
Jul 27 10:24:20 decoder asadmin[877]: Successfully started the domain : domain1
Jul 27 10:24:20 decoder asadmin[877]: domain Location: /usr/share/glassfish3/glassfish/domains/domain1
Jul 27 10:24:20 decoder asadmin[877]: Log File: /usr/share/glassfish3/glassfish/domains/domain1/logs/server.log
Jul 27 10:24:20 decoder asadmin[877]: Admin Port: 4848
Jul 27 10:24:20 decoder asadmin[877]: Command start-domain executed successfully.
Jul 27 10:24:20 decoder systemd[1]: Started GlassFish Server.
Jul 27 11:17:22 decoder systemd[1]: glassfish.service: main process exited, code=exited, status=10/n/a
Jul 27 11:17:22 decoder asadmin[9366]: CLI306 Warning - The server located at /usr/share/glassfish3/glassfish/domains/domain1 is not running.
Jul 27 11:17:22 decoder asadmin[9366]: Command stop-domain executed successfully.
Jul 27 11:17:22 decoder systemd[1]: Unit glassfish.service entered failed state.
Here is the GF server.log:
[#|2016-07-27T11:17:20.805+0200|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.com.sun.enterprise.v3.admin|_ThreadID=23;_ThreadName=Thread-2;|Server restart initiated|#]
[#|2016-07-27T11:17:20.810+0200|WARNING|glassfish3.1.2|javax.enterprise.system.tools.admin.com.sun.enterprise.v3.admin|_ThreadID=23;_ThreadName=Thread-2;|There should be only 1 primordial module but 0 primordial modules were found.|#]
Jul 27, 2016 11:17:21 AM com.sun.enterprise.admin.launcher.GFLauncherLogger info
INFO: JVM invocation command line:
-XX:+UnlockDiagnosticVMOptions
-XX:PermSize=64m
-XX:MaxPermSize=192m
-XX:NewRatio=2
-Xmx512m
-client
-javaagent:/usr/share/glassfish3/glassfish/lib/monitor/flashlight-agent.jar
-Dfelix.fileinstall.disableConfigSave=false
-Djavax.net.ssl.keyStore=/usr/share/glassfish3/glassfish/domains/domain1/config/keystore.jks
-Djava.awt.headless=true
-Dfelix.fileinstall.poll=5000
-Djava.endorsed.dirs=/usr/share/glassfish3/glassfish/modules/endorsed:/usr/share/glassfish3/glassfish/lib/endorsed
-Dfelix.fileinstall.bundles.startTransient=true
-Djavax.net.ssl.trustStore=/usr/share/glassfish3/glassfish/domains/domain1/config/cacerts.jks
-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as
-DANTLR_USE_DIRECT_CLASS_LOADING=true
-Djava.security.auth.login.config=/usr/share/glassfish3/glassfish/domains/domain1/config/login.conf
-Dgosh.args=--nointeractive
-Dosgi.shell.telnet.maxconn=1
-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
-Dfelix.fileinstall.dir=/usr/share/glassfish3/glassfish/modules/autostart/
-Dosgi.shell.telnet.port=6666
-Djava.security.policy=/usr/share/glassfish3/glassfish/domains/domain1/config/server.policy
-Dfelix.fileinstall.log.level=2
-Duser.timezone=Europe/Zurich
-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-Dosgi.shell.telnet.ip=127.0.0.1
-Dcom.sun.aas.instanceRoot=/usr/share/glassfish3/glassfish/domains/domain1
-Dcom.sun.aas.installRoot=/usr/share/glassfish3/glassfish
-Djava.ext.dirs=/usr/java/jdk1.6.0_45/lib/ext:/usr/java/jdk1.6.0_45/jre/lib/ext:/usr/share/glassfish3/glassfish/domains/domain1/lib/ext
-Dfelix.fileinstall.bundles.new.start=true
Jul 27, 2016 11:17:22 AM com.sun.enterprise.admin.launcher.GFLauncherLogger info
INFO: Successfully launched in 3 msec.
I've no SELinux denials, here is the only trace:
type=SERVICE_STOP msg=audit(1467638602.044:1652): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=' comm="glassfish" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Setting selinux mode to permissive has no effect. I've absolutely no idea what's going wrong...
I've also tested GF 3.1.2.2 on Centos 6 and it works. Maybe it is related to systemctl (Fedora 20 and Centos 7 both uses systemctl by default)?
I had to leave the default admin port in 8080 and to add a "Port Forwarding" Firewall rule from 80 to 8080 and then the Glassfish restart works correctly.
From https://serverfault.com/a/112798/393296 and the FirewallD rule was (for Centos7)
sudo firewall-cmd --zone="dmz" --add-forward-port=port=80:proto=tcp:toport=8080 --permanent
sudo firewall-cmd --reload
Note: Remember to change your zone to your active one (in this case my active zone is dmz -- more info about FirewallD Centos7)
need to add to the section [Service] Restart=on-failure

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