The tomcat installation on both — working and non-working — are clean, fresh 
download-n-untar distributions from the Apache web site; I have not deployed 
any web apps or modified any configuration files.

Moreover, as I point out, if I manually run catalina.sh in ../bin, the server 
starts up fine, and keeps running, and responds correctly to requests (i.e., I 
get the Tomcat 8.5 installation success screen).

So the problem does not appear to be with tomcat and its configuration, per se, 
but trying to get systems / systemctl to work.  If Tomcat itself was 
mis-configured, I would think that it wouldn’t start up when I manually ran 
catalina.sh in ../bin, and response to requests.

So the assistance I am seeking is related to how to get it to start and run 
with systemctl.  In the past (going back many years to tomcat 3 I believe), I 
always wrote /etc/init.d scripts, which were shell scripts, but now trying to 
get this to work with systemd / systemctl (which are configured with .service 
parameter files in /usr/lib/systemd/system, and not shell scripts).

Thanks.

> On Jan 22, 2019, at 10:26 PM, Christopher Schultz 
> <ch...@christopherschultz.net> wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> David,
> 
> On 1/22/19 18:52, David Filip wrote:
>> Hi All,
>> 
>> I seem to be having troubles getting Tomcat 8.5 to start on an 
>> Amazon Linux 2 server with systemctl.  The problem seems to be
>> that after starting tomcat, it always immediately tries to shut
>> down. From /var/log:
>>> Jan 22 23:13:32 cloud systemd: Starting Tomcat 8.5 servlet
>>> container...
>> Jan 22 23:13:32 cloud startup.sh: Tomcat started. Jan 22 23:13:32
>> cloud systemd: Started Tomcat 8.5 servlet container. Jan 22
>> 23:13:33 cloud shutdown.sh: Jan 22, 2019 11:13:33 PM
>> org.apache.catalina.startup.Catalina stopServer Jan 22 23:13:33
>> cloud shutdown.sh: SEVERE: Could not contact [localhost:[8005]].
>> Tomcat may not be running. Jan 22 23:13:33 cloud shutdown.sh: Jan
>> 22, 2019 11:13:33 PM org.apache.catalina.startup.Catalina
>> stopServer Jan 22 23:13:33 cloud shutdown.sh: SEVERE:
>> Catalina.stop: Jan 22 23:13:33 cloud shutdown.sh:
>> java.net.ConnectException: Connection refused (Connection refused) 
>> Jan 22 23:13:33 cloud shutdown.sh: at
>> java.net.PlainSocketImpl.socketConnect(Native Method) Jan 22
>> 23:13:33 cloud shutdown.sh: at
>> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.jav
> a:350)
>> 
>> 
> Jan 22 23:13:33 cloud shutdown.sh: at
> java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImp
> l.java:206)
>> Jan 22 23:13:33 cloud shutdown.sh: at
>> java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:
> 188)
>> 
>> 
> Jan 22 23:13:33 cloud shutdown.sh: at
> java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
>> Jan 22 23:13:33 cloud shutdown.sh: at
>> java.net.Socket.connect(Socket.java:589) Jan 22 23:13:33 cloud
>> shutdown.sh: at java.net.Socket.connect(Socket.java:538) Jan 22
>> 23:13:33 cloud shutdown.sh: at
>> java.net.Socket.<init>(Socket.java:434) Jan 22 23:13:33 cloud
>> shutdown.sh: at java.net.Socket.<init>(Socket.java:211) Jan 22
>> 23:13:33 cloud shutdown.sh: at
>> org.apache.catalina.startup.Catalina.stopServer(Catalina.java:503) 
>> Jan 22 23:13:33 cloud shutdown.sh: at
>> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) Jan 22
>> 23:13:33 cloud shutdown.sh: at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:62)
>> 
>> 
> Jan 22 23:13:33 cloud shutdown.sh: at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:43)
>> Jan 22 23:13:33 cloud shutdown.sh: at
>> java.lang.reflect.Method.invoke(Method.java:498) Jan 22 23:13:33
>> cloud shutdown.sh: at
>> org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:406)
>> 
>> 
> Jan 22 23:13:33 cloud shutdown.sh: at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:498)
>> Jan 22 23:13:33 cloud shutdown.sh: The stop command failed.
>> Attempting to signal the process to stop through OS signal. Jan 22
>> 23:13:34 cloud shutdown.sh: Tomcat stopped.
>> 
>> However, I can manually start tomcat on the same server, which
>> works fine, e.g.:
>> 
>> # cd /opt/tomcat/bin # ./catalina.sh start Using CATALINA_BASE:
>> /opt/tomcat Using CATALINA_HOME:   /opt/tomcat Using
>> CATALINA_TMPDIR: /opt/tomcat/temp Using JRE_HOME:        /usr Using
>> CLASSPATH:
>> /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar 
>> Tomcat started.
>> 
>> # ps -aef | grep java root      8598     1 50 23:17 pts/0
>> 00:00:02 /usr/bin/java
>> -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties
>> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
>> -Djdk.tls.ephemeralDHKeySize=2048
>> -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
>> -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
>> -Dignore.endorsed.dirs= -classpath
>> /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
>> -Dcatalina.base=/opt/tomcat -Dcatalina.home=/opt/tomcat
>> -Djava.io.tmpdir=/opt/tomcat/temp
>> org.apache.catalina.startup.Bootstrap start
>> 
>> And it stays running until I explicitly shut it down.  However,
>> what is most odd is that I also have tomcat 8.5 running on a
>> DIFFERENT system, which was built with a generic CentOS 7.5
>> download (vs. an Amazon Linux 2 EC2 server), but USING THE SAME
>> SERVICE FILE.  I was under the impression that the Amazon Linux 2
>> is based on CentOS 7.
> I think it's supposed to be "CentOS/RHEL Compatible" but not
> necessarily "based upon" one particular version  of CentOS/RHEL.
> 
>> Or, at least I can’t find the difference.  And while Google’ing 
>> around, I did find other mentions of the exact same problem,
>> whereby tomcat tries to immediately shut down after starting up,
>> but alas without a posted solution.  I was wondering if anyone out
>> there might have come across this problem, and have any advice?
> I'll point out that Tomcat isn't just shutting down because it's
> unhappy about something. The shutdown.sh script is being invoked,
> probably by systemd. It would be great if you could just read the
> scripts to find out what's going on, but evidently scripts are so passe.
> 
> I believe this is a problem with system and/or the configuration it's
> working with, not Tomcat itself.
> 
>> Also, the one difference was that on CentOS 7 — which works — I am 
>> using Oracle Java 8 java installed on /opt/java, and on AWS — which
>> does not work — I was using OpenJDK 8.  However, I have also tried
>> installing the same Oracle Java 8 on Amazon Linux 2 in /opt/java,
>> and then changing:
>> 
>> Environment="JAVA_HOME=/opt/java“
>> 
>> and have the exact same problem.  So I am running out of things to
>> try!
> 
> I've never had any problem with OpenJDK; that's unlikely to be the issue
> .
> 
>> Actually, one other minor difference is that the CentOS 7.5 server
>> has tomcat 8.5.34 and the AWS server has tomcat 8.5.37, and I am 
>> assuming that the difference in patch level is not relevant, but
>> am mentioning it nonetheless> Finally, nothing else is currently
>> running on port 8080, e.g.:
>> 
>> # telnet localhost 8080 Trying 127.0.0.1... telnet: connect to
>> address 127.0.0.1: Connection refused
>> 
>> The only thing I see written to /opt.tomcat/logs/catalina.out is:
>> 
>> Java HotSpot(TM) 64-Bit Server VM warning: ignoring option
>> PermSize=256m; support was removed in 8.0 Java HotSpot(TM) 64-Bit
>> Server VM warning: ignoring option MaxPermSize=384m; support was
>> removed in 8.0
>> 
>> Which tells me that it is finding the JVM, but that I have to
>> remove the PermGen parameters (but I am leaving in as an indication
>> that the JVM is being run, but that the warning should not be
>> causing my problem because it is ignoring the obsolete
>> parameters).> I am documenting first what works (CentOS 7.5),
>> followed by what doesn’t work (AWS).  If anyone has any ideas, or
>> can spot the difference, or has any ideas on what else I can check,
>> please let me know.
> 
> If you look at the conf/server.xml files in both working and
> non-working environments, do they both have a "shutdown port"
> configured? What HTTP and./or AJP ports do they have configured?
> 
> I'm wondering if systemd is trying to poll the process to see if it's
> "up" and that check is failing, causing it to pull the process down
> gracefully.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ 
> <https://www.enigmail.net/>
> 
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxH3u4ACgkQHPApP6U8
> pFhpyQ/+OiWpNTgS/LuxVJdA4M/K3I6WByx9mSUpaYMrjrSOX1iRP/nK8Sgo4zHD
> +FU//FvxFxmU9TMnZSkcTOEvm4oJVDyKmXOufhvK+RTzrEf+biEOm2JAF7vZPq+2
> fVsIkC2KKCvbP6OkPMpKp0FSjuPEIYqgFCPeW1aIHIXO0n70BdQ94xAI5qBrtjfN
> fKeKpVvXrq7xvAUq+X2CApMkDvlt7rg1hc1qr4UIEynCQHJzPSv0sKCNzU5JxBb2
> o5pnSHRG1MFHY4ceIcT8/7TRXCo899s3GH5Qfl1dsZfAqdSeSUGFZjluDFuEPorg
> FAil8y+fy26QG9g5LYi2NuVqIYwYM6lEPKepIuz9oPHikPVzoaFeuHKFSaKEbX8A
> X6DMCc1bqUdXSBmblXfS8QdXcV8M5ExlLYnJmuh1cAVjw+31geC9ElAVXCiYkdls
> 5pWCvd3GyvgmiaixFIG2La7ixw8Nj/clTJq7NBEBPp/w9DURIqI0PKMk38DE+Kvo
> ykmynJ84bc5lOToifRj6VRp/6QRLyXnVheUfx7zA4DffWLGwISyrYjesO9G3Y+cl
> yXR5g0zL/DAHoXCBQzEfSBtKJtXuUQvhL+w7h2j/VND8Jfq4F4h5maOuIhu5fb9G
> KIc0V8QeR00SQl1nKQIj0qTEMsKp8jS1k2enbOdESSeH3cyB/Us=
> =WFgM
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org 
> <mailto:users-unsubscr...@tomcat.apache.org>
> For additional commands, e-mail: users-h...@tomcat.apache.org 
> <mailto:users-h...@tomcat.apache.org>

Reply via email to