Thursday, May 23, 2019

403 Access Denied when opening the Manager App

After you installed the Apache Tomcat server and successfully launched the <host>:8080 web page, you click on the Manager App button, and you get a 403 Access Denied message.

To fix it

1. Open the $CATALINA_BASE/conf/tomcat-users.xml file and add the following to the <tomcat-users> section.

          <user username="admin" password="goanywhere" roles="admin-gui,manager-gui" />

2. If you are accessing the Tomcat server from a remote computer, open or create the file: $CATALINA_BASE/conf/Catalina/localhost/manager.xml, and add the below to the file.

          <Context privileged="true" antiResourceLocking="false"
                    docBase="${catalina.home}/webapps/manager">
                    <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
         </Context>

3. Restart the tomcat server: sudo systemctl restart tomcat.service

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details.

When you run the command: sudo systemctl start tomcat.service, you get the following message.

         Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details.

To find out the cause of the problem, you run the following command according to the message.

          sudo journalctl -xe

Below is a smaple output of the above command.

]$ sudo journalctl -xe
May 23 11:21:02 cstestdbc7 systemd[1]: tomcat.service failed.
May 23 11:21:02 cstestdbc7 sudo[52164]: pam_unix(sudo:session): session closed for user root
May 23 11:21:02 cstestdbc7 polkitd[128065]: Unregistered Authentication Agent for unix-process:52165:864308901 (system bus name :1.May 23 11:21:25 testmachine7 sudo[52188]:      jsmieh : TTY=pts/13 ; PWD=/opt ; USER=root ; COMMAND=/bin/systemctl daemon-reload
May 23 11:21:25 tesmachine7 sudo[52188]: pam_unix(sudo:session): session opened for user root by jsmith(uid=0)
May 23 11:21:26 testmachine7 polkitd[128065]: Registered Authentication Agent for unix-process:52189:864311216 (system bus name :1.93May 23 11:21:26 testmachine7 systemd[1]: Reloading.
May 23 11:21:26 testmachine7 systemd[1]: [/usr/lib/systemd/system/bolt.service:11] Unknown lvalue 'MemoryDenyWriteExecute' in sectionMay 23 11:21:26 testmachine7 systemd[1]: [/usr/lib/systemd/system/bolt.service:13] Unknown lvalue 'ProtectControlGroups' in section 'May 23 11:21:26 testmachine7 systemd[1]: [/usr/lib/systemd/system/bolt.service:15] Unknown lvalue 'ProtectKernelModules' in section 'May 23 11:21:26 testmachine7 systemd[1]: [/usr/lib/systemd/system/bolt.service:18] Unknown lvalue 'RestrictRealtime' in section 'ServMay 23 11:21:26 testmachine7 systemd[1]: [/usr/lib/systemd/system/bolt.service:19] Unknown lvalue 'ReadWritePaths' in section 'ServicMay 23 11:21:26 testmachine7 polkitd[128065]: Unregistered Authentication Agent for unix-process:52189:864311216 (system bus name :1.May 23 11:21:26 testmachine7 sudo[52188]: pam_unix(sudo:session): session closed for user root
May 23 11:21:30 testmachine7 sudo[52217]:      jsmith : TTY=pts/13 ; PWD=/opt ; USER=root ; COMMAND=/bin/systemctl start tomcat.servicMay 23 11:21:30 testmachine7 sudo[52217]: pam_unix(sudo:session): session opened for user root by jsmith(uid=0)
May 23 11:21:30 testmachine7 polkitd[128065]: Registered Authentication Agent for unix-process:52218:864311710 (system bus name :1.93May 23 11:21:30 testmachine7 systemd[1]: Starting Apache Tomcat Web Application Container...
-- Subject: Unit tomcat.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat.service has begun starting up.
May 23 11:21:30 testmachine7 systemd[52224]: Failed at step EXEC spawning /opt/tomcat/bin/startup.sh: No such file or directory
-- Subject: Process /opt/tomcat/bin/startup.sh could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /opt/tomcat/bin/startup.sh could not be executed and failed.
--
-- The error number returned by this process is 2.
May 23 11:21:31 testmachine7 systemd[1]: tomcat.service: control process exited, code=exited status=203
May 23 11:21:31 testmachine7 systemd[1]: Failed to start Apache Tomcat Web Application Container.
-- Subject: Unit tomcat.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

The launch of tomcat failed because the /opt/tomcat/bin/startup.sh could not be executed or does not exist. Check your /etc/systemd/system/tomcat.service file to ensure that the directory for the startup.sh is correct, and the directories for all the other entries are correct.

Check your path permissions to the startup.sh to ensure that it is executable.

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

Friday, May 17, 2019

Deploy a web application WAR to Tomcat server

Below are two ways to deploy a WAR file to the Tomcat server.

A. Through the Apache Tomcat manager

  1. Launch your Tomcat management page by entering <your Tomcat server host>:8080 to a web brower..
  2. Click the Manager App button, enter the username and password to login to the Tomcat Web Application Manager site.
  3. Under the Deploy box, click the Choose File button following the text of Select WAR to uplaod, select the WAR file, and click the Deploy button.
  4. You will see a message at the top of the page saying OK.
  5. You should be able to see the project you just deployed in the Applications box. If you click on the path, it will take you to the initial screen of your application displayed in a web browser.
B. Copy the WAR file to the webapps folder in your Tomcat home, and then restart your Tomcat server.


-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

Get and use the Tomcat home in Java

You can get the Tomcat home directory from a java file that is part of the web application deployed into the Tomcat server.

            System.getProperty("catalina.base");

For example, if you want to read a file, myConfigure.txt, located in the Tomcat directory.

            FileReader reader = new FileReader(System.getProperty("catalina.base") + File.separator + "myConfigure.txt");


-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

Monday, May 6, 2019

Install Tomcat 9 as the web server in NetBeans 11.0

Download the Tomcat core zip file from https://tomcat.apache.org/download-90.cgi. The file downloaded is apache-tomcat-9.9.19.

Extract files from the zip file to the C:\Program Files directory.

Open the NetBeans 11.0, click on Tools in the top menu and select Servers.


In the popup window, click the Add Server button.


In the new popup window, select Apache Tomcat or TomEE from the server list. Then, click the Next button.



In the popup window, enter the Tomcat location as the Server location, fill in the username and password fields, and click the Finish button.


It will take you back to the Server screen, which now looks like the one below. Click the Close button to close the window.


To start the Tomcat server, right click the Apache Tomcat or TomEE under Servers in the Services tab, and select Start.



In a few seconds, the server is available to view at http://localhost:8080


Right click on your web service project and select run to start your website.

 -----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

Reference:

1. Installing Tomcat 7 and Configuring as Server in NetBeans