Results 1 to 6 of 6

Thread: enable tomcat9 as systemd service

  1. #1

    Default enable tomcat9 as systemd service

    Hi,

    I have installed tomcat9 in /opt/tomcat9 folder .
    after execute /opt/tomcat9/bin/startup.sh , I able to access the tomcat mainpage, manager /host-manager page . but when i try to enable it as systemd service I get error when i try to access the mainpage

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
    HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.index_jsp

    type Exception report

    message java.lang.ClassNotFoundException: org.apache.jsp.index_jsp

    description The server encountered an internal error that prevented it from fulfilling this request.

    exception
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////


    Here a simple script for tomcat9.service

    [Unit]
    Description=Apache Tomcat Web Application Container
    After=syslog.target network.target

    [Service]
    Type=forking
    ExecStart=/opt/tomcat9/bin/startup.sh
    ExecStop=/opt/tomcat9/bin/shutdown.sh
    User=tomcat
    Group=tomcat

    [Install]
    WantedBy=multi-user.targer


    ////////////////////////////////////////////////////////////////////////////////////////////////////////
    return by systemctl status after I execute systemctl start tomcat9.service

    Warning: tomcat9.service changed on disk. Run 'systemctl daemon-reload' to reload units.
    bt01:/usr/lib/systemd/system # systemctl status tomcat9.service -l
    ● tomcat9.service - Apache Tomcat Web Application Container
    Loaded: loaded (/usr/lib/systemd/system/tomcat9.service; disabled; vendor preset: disabled)
    Active: active (running) since Fri 2016-05-06 17:44:19 SGT; 3s ago
    Process: 2625 ExecStop=/opt/tomcat9/bin/shutdown.sh (code=exited, status=0/SUCCESS)
    Process: 2786 ExecStart=/opt/tomcat9/bin/startup.sh (code=exited, status=0/SUCCESS)
    Main PID: 2802 (java)
    Tasks: 23 (limit: 512)
    CGroup: /system.slice/tomcat9.service
    └─2802 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat9/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -classpath /opt/tomcat9/bin/bootstrap.jar:/opt/tomcat9/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat9 -Dcatalina.home=/opt/tomcat9 -Djava.io.tmpdir=/opt/tomcat9/temp org.apache.catalina.startup.Bootstrap start

    May 06 17:44:19 bt01 systemd[1]: Starting Apache Tomcat Web Application Container...
    May 06 17:44:19 bt01 startup.sh[2786]: Tomcat started.
    May 06 17:44:19 bt01 systemd[1]: Started Apache Tomcat Web Application Container.
    Warning: tomcat9.service changed on disk. Run 'systemctl daemon-reload' to reload units.




    am I missing something ?

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,143
    Blog Entries
    2

    Default Re: enable tomcat9 as systemd service

    Although I don't personally run Tomcat today (and haven't for many years)

    Tomcat is a jsp container architecture running on Apache.

    I'm guessing your Apache Server isn't yet running.

    I don't know how this is intended to run on today's openSUSE for sure, but I'd guess that you only need to start your Apache web server and Tomcat should automatically be available.

    Am not sure why there would be a Tomcat service...Speculating a bit but based on historical architecture, I'd guess it should simply be a loadable service but <not> enabled because it really isn't a true standalone service but is simply implemented on top of Apache.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    20,287
    Blog Entries
    1

    Default Re: enable tomcat9 as systemd service

    Code:
    Warning: tomcat9.service changed on disk. Run 'systemctl daemon-reload' to reload units.
    Did you do the following yet?
    Code:
    systemctl daemon-reload

  4. #4
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    20,287
    Blog Entries
    1

    Default Re: enable tomcat9 as systemd service

    Also, I note
    Code:
    Loaded: loaded (/usr/lib/systemd/system/tomcat9.service; disabled; vendor preset: disabled)
    To enable it permanently (for subsequent boots), do this first
    Code:
    systemctl enable tomcat9

  5. #5
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    20,287
    Blog Entries
    1

    Default Re: enable tomcat9 as systemd service

    Be careful with typos. You have
    Code:
    [Install]
    WantedBy=multi-user.targer
    It should be
    Code:
    [Install]
    WantedBy=multi-user.target
    BTW, there isn't a syslog.target with openSUSE, so although it won't hurt to have it included, it isn't relevant/necessary to have it listed explicitly. Amend it like this

    Code:
    [Unit]
    Description=Apache Tomcat Web Application Container
    After=network.target
    Info:
    https://lists.opensuse.org/opensuse-.../msg00102.html

  6. #6

    Default Re: enable tomcat9 as systemd service

    After try and error . this script work. I can upload Birt report war and run the report.
    but I still don't know if this script is correct.



    [Unit]
    Description=Apache Tomcat Web Application Container
    After=syslog.target network.target

    [Service]
    User=tomcat
    Group=tomcat
    Environment=CATALINA_BASE=/opt/tomcat9
    Environment=CATALINA_HOME=/opt/tomcat9
    Environment=JRE_HOME=/usr/lib64/jvm/jre
    Environment=CATALINA_TMPDIR=/opt/tomcat9/temp
    Environment= CLASSPATH=/opt/tomcat9/bin/bootstrap.jar:/opt/tomcat9/bin/tomcat-juli.jar
    Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
    Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

    ExecStart=/opt/tomcat9/bin/catalina.sh run
    ExecStop=/opt/tomcat9/bin/catalina.sh stop

    [Install]
    WantedBy=multi-user.target

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •