CodeWalrus

Development => Web => Topic started by: p2 on December 01, 2016, 04:06:58 PM

Title: tomcat and ubuntu
Post by: p2 on December 01, 2016, 04:06:58 PM
I tried to setup a Java Servlet on a Tomcat-8 on Ubuntu server and ran in thousands of problems. Maybe you can learn from them :) Even if not... I stilll got +1 post (quantity, yaay) ^^
I am referring to tomcat8 that was NOT installed using the official repository. If oyu used it (recommended) many things (like paths) will be different.

How to solve stupid problems with servlets on tomcat:

to see if your tomcat is working, jost go on yourdomain.com:8080/
you should then see the welcome screen of tomcat:
(http://img.codewalr.us/tomcat1.jpg)


[spoiler= I DO NOT SEE THIS SCREEN ]if you're NOT seeing this, you should check if your tomcat is running.
To do this go to the terminal and enter:
sudo systemctl restart tomcat
systemctl status tomcat

you should see something like this:
(http://img.codewalr.us/tomcat2.jpg)
to go back press CTRL + C
[spoiler= NUUU, MINE IS DIFFERENT ]
if you're getting different results (or in general if that text does NOT say "active (running)" then you should concider a reinstallation as this will be insanely hard to fix.[/spoiler]
[spoiler= YAAAY, SAME HERE ]
If you see this but the site isn't working, that probably means your permission aren't set correctly.
You should make sure the owners/groups are set correctly.
To set them, enter this:
sudo chown tomcat:tomcat /opt/tomcat/webapps/MYFILE.WAR
sudo chown tomcat:tomcat /opt/tomcat/webapps/
sudo systemctl restart tomcat

(http://img.codewalr.us/tomcat3.jpg)
You should put in the correct name for your WAR file (your servlet).
Then you should again check if you see the site now.
[spoiler= NUU STILL NOTHING ]
You should also concider a little reinstallation as your problem will be pretty hard to fix... I'm sorry :/
[/spoiler]
[spoiler= YAAAAY SEE IT ]Great. Your problem was solved ^^
If your servlet still wont work, follow these instructions a second round :)[/spoiler]
[/spoiler]
[/spoiler]
[spoiler= YEAH, CAN SEE IT ]
Great, that means at least your Tomcat is running.
But your servler is still not working... else you wouldn't read this. :/
The first step now is to check the logs. The fastest way to do so is just reading them directly on the Server.
To read the logs, do this:
sudo nano /opt/tomcat/logs/catalina.1984-01-01.log
(http://img.codewalr.us/tomcat4.jpg)
Please be aware you have to enter the current date in the filename.
The result should look like this: (sorry for the quality)
(http://img.codewalr.us/tomcat5.jpg)
You can scroll the text up and down with the arrow keys.
If all of the text looks about the same (no strange paragraphs or super short lines) thats a good sign :)
To exit this, press CTRL + X

[spoiler= AAAH THATS 9001 LINES!! ]
In this case we ahould clear your log files and create some new entries.
Lets first delete the old files:
sudo rm /opt/tomcat/logs/ -R
sudo mkdir /opt/tomcat/logs
sudo chown tomcat:tomcat /opt/tomcat/logs -R

(http://img.codewalr.us/tomcat6.jpg)
Then you should try to create some new entries by reloading the site and accessing the servlet again.
Afterwards try to read the logs, again:
sudo nano /opt/tomcat/logs/catalina.1984-01-01.log
(http://img.codewalr.us/tomcat4.jpg)
Again, please be aware you have to enter the current date in the filename.
The result should look like this: (sorry for the quality)
(http://img.codewalr.us/tomcat5.jpg)
You can scroll the text up and down with the arrow keys.
If all of the text looks about the same (no strange paragraphs or super short lines) thats a good sign :)
To exit this, press CTRL + X
[spoiler= JEP, SEEMS FINE ]
Okey, then that might mean something with your servlet isn't right. Your tomcat seems not to be the problem.
You should now check if your servlet was automatically unpacked by tomcat. If not, it didnt even load it in the first place.
To do that, enter this:
sudo dir /opt/tomcat/webapps/
(http://img.codewalr.us/tomcat7.jpg)
As a result you get a list of all files/folders in your webapps/ folder.
There should be a directory (folder) names the same as your WAR file:
(http://img.codewalr.us/tomcat8.jpg)
[spoiler= YAAAY IT'S THERE]THATS NO REASON TO BE HAPPY!!
Actually that means you TOTALLY messed omething up.
Go reinstall your tomcat. Nothing else will help you I'm afraid.[/spoiler]
[spoiler= NUU, NO SUCH FOLDER! ]That mean's your Servlet wasn't accepted by tomcat because you didn't set the group/owner correctly.
To fix that, type this:
sudo chown tomcat:tomcat /opt/tomcat/webapps -R
sudo systemctl restart tomcat

(http://img.codewalr.us/tomcat9.jpg)
After that please retry if it works now.
[spoiler= YAAAY MY SERVLET WORKS]Fnie. Now bring me cookies![/spoiler]
[spoiler= NUUU *CRY* STILL NOT WORKING [/spoiler]
in that case.. you're just stupid. You messed something up and I cant even imagine how.
Go reinstall your tomcat.
And be ashamed of yourself...
bye <3[/spoiler]
[/spoiler]
[spoiler= NUU, STILL  NO ENTRIES! ]
If your log file is still empty that means you should definitely try a reinstallation. Else you won't be happy anytime soon...
[/spoiler]
[spoiler= NUU, ERROR MESSAGES!! ]
Actually thats great as you can now get some REAL help.
Just search the internet for them :)
Byye <3[/spoiler]
[/spoiler]
[spoiler= HUH? IT'S EMPTY! ]
If your log file is still empty that means you should definitely try a reinstallation. Else you won't be happy anytime soon...
[/spoiler]
[spoiler= NUU, ERROR MESSAGES!! ]
Actually thats great as you can now get some REAL help.
Just search the internet for them :)
Byye <3[/spoiler]
[/spoiler]
[spoiler= NUU, ERROR MESSAGES!! ]
Actually thats great as you can now get some REAL help.
Just search the internet for them :)
Byye <3[/spoiler]
[spoiler= HUH? IT'S EMPTY! ]
In this case lets recreate the logs folder and restart tomcat.
Please enter this:
sudo rm /opt/tomcat/logs/ -R
sudo mkdir /opt/tomcat/logs
sudo chown tomcat:tomcat /opt/tomcat/logs -R

(http://img.codewalr.us/tomcat6.jpg)
Then you should try to create some new entries by reloading the site and accessing the servlet again.
Afterwards try to read the logs, again:
sudo nano /opt/tomcat/logs/catalina.1984-01-01.log
(http://img.codewalr.us/tomcat4.jpg)
Again, please be aware you have to enter the current date in the filename.
The result should look like this: (sorry for the quality)
(http://img.codewalr.us/tomcat5.jpg)
You can scroll the text up and down with the arrow keys.
If all of the text looks about the same (no strange paragraphs or super short lines) thats a good sign :)
To exit this, press CTRL + X
[spoiler= ERM... IT'S STILL EMPTY ]
If your log file is still empty even now, then your tomcat is beyond repair (at least I think so).
Please try a reinstallation.
Thx for reading <3[/spoiler]
[spoiler= NUU, ERROR MESSAGES!! ]
Actually thats great as you can now get some REAL help.
Just search the internet for them :)
Byye <3[/spoiler]
[spoiler= JEP, SEEMS FINE NOW ]
Okey, then that might mean something with your servlet isn't right. Your tomcat seems not to be the problem.
You should now check if your servlet was automatically unpacked by tomcat. If not, it didnt even load it in the first place.
To do that, enter this:
sudo dir /opt/tomcat/webapps/
(http://img.codewalr.us/tomcat7.jpg)
As a result you get a list of all files/folders in your webapps/ folder.
There should be a directory (folder) names the same as your WAR file:
(http://img.codewalr.us/tomcat8.jpg)
[spoiler= YAAAY IT'S THERE]THATS NO REASON TO BE HAPPY!!
Actually that means you TOTALLY messed omething up.
Go reinstall your tomcat. Nothing else will help you I'm afraid.
[/spoiler]
[spoiler= NUU, NO SUCH FOLDER! ]That mean's your Servlet wasn't accepted by tomcat because you didn't set the group/owner correctly.
To fix that, type this:
sudo chown tomcat:tomcat /opt/tomcat/webapps -R
sudo systemctl restart tomcat

(http://img.codewalr.us/tomcat9.jpg)
After that please retry if it works now.
[spoiler= YAAAY MY SERVLET WORKS]Fnie. Now bring me cookies![/spoiler]
[spoiler= NUUU *CRY* STILL NOT WORKING [/spoiler]
in that case.. you're just stupid. You messed something up and I cant even imagine how.
Go reinstall your tomcat.
And be ashamed of yourself...
bye <3[/spoiler]
[/spoiler][/spoiler][/spoiler]
[spoiler= JEP, SEEMS FINE ]
Okey, then that might mean something with your servlet isn't right. Your tomcat seems not to be the problem.
You should now check if your servlet was automatically unpacked by tomcat. If not, it didnt even load it in the first place.
To do that, enter this:
sudo dir /opt/tomcat/webapps/
(http://img.codewalr.us/tomcat7.jpg)
As a result you get a list of all files/folders in your webapps/ folder.
There should be a directory (folder) names the same as your WAR file:
(http://img.codewalr.us/tomcat8.jpg)
[spoiler= YAAAY IT'S THERE]THATS NO REASON TO BE HAPPY!!
Actually that means you TOTALLY messed omething up.
Go reinstall your tomcat. Nothing else will help you I'm afraid.[/spoiler]
[spoiler= NUU, NO SUCH FOLDER! ]That mean's your Servlet wasn't accepted by tomcat because you didn't set the group/owner correctly.
To fix that, type this:
sudo chown tomcat:tomcat /opt/tomcat/webapps -R
sudo systemctl restart tomcat

(http://img.codewalr.us/tomcat9.jpg)
After that please retry if it works now.
[spoiler= YAAAY MY SERVLET WORKS]Fnie. Now bring me cookies![/spoiler]
[spoiler= NUUU *CRY* STILL NOT WORKING [/spoiler]
in that case.. you're just stupid. You messed something up and I cant even imagine how.
Go reinstall your tomcat.
And be ashamed of yourself...
bye <3[/spoiler]
[/spoiler][/spoiler]
[/spoiler]
If you see any mistakes, pls tell me
*10000 letters ^.^
Title: Re: tomcat and ubuntu
Post by: global2016 on December 14, 2016, 02:38:57 AM
up
Title: Re: tomcat and ubuntu
Post by: Dream of Omnimaga on December 14, 2016, 05:25:45 AM
Quote from: global2016 on December 14, 2016, 02:38:57 AM
up
Hi, do you need any help?