Alternatively, join us on Discord.

tomcat and ubuntu

Started by p2, December 01, 2016, 04:06:58 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

p2

December 01, 2016, 04:06:58 pm Last Edit: January 20, 2017, 02:29:03 pm by p2
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:



I DO NOT SEE THIS SCREEN : ShowHide
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:

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.

YAAAY, SAME HERE : ShowHide

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


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 :/

YAAAAY SEE IT : ShowHide
Great. Your problem was solved ^^
If your servlet still wont work, follow these instructions a second round :)

[/spoiler]
[/spoiler]
YEAH, CAN SEE IT : ShowHide

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

Please be aware you have to enter the current date in the filename.
The result should look like this: (sorry for the quality)

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


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

Again, please be aware you have to enter the current date in the filename.
The result should look like this: (sorry for the quality)

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/

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:

[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.

NUU, NO SUCH FOLDER! : ShowHide
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


After that please retry if it works now.
[spoiler= YAAAY MY SERVLET WORKS]Fnie. Now bring me cookies!

NUUU *CRY* STILL NOT WORKING [/spoiler: ShowHide

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]
NUU, STILL  NO ENTRIES! : ShowHide

If your log file is still empty that means you should definitely try a reinstallation. Else you won't be happy anytime soon...

NUU, ERROR MESSAGES!! : ShowHide

Actually thats great as you can now get some REAL help.
Just search the internet for them :)
Byye <3

[/spoiler]
HUH? IT'S EMPTY! : ShowHide

If your log file is still empty that means you should definitely try a reinstallation. Else you won't be happy anytime soon...

NUU, ERROR MESSAGES!! : ShowHide

Actually thats great as you can now get some REAL help.
Just search the internet for them :)
Byye <3

[/spoiler]
NUU, ERROR MESSAGES!! : ShowHide

Actually thats great as you can now get some REAL help.
Just search the internet for them :)
Byye <3

HUH? IT'S EMPTY! : ShowHide

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


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

Again, please be aware you have to enter the current date in the filename.
The result should look like this: (sorry for the quality)

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

NUU, ERROR MESSAGES!! : ShowHide

Actually thats great as you can now get some REAL help.
Just search the internet for them :)
Byye <3

JEP, SEEMS FINE NOW : ShowHide

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/

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:

[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.

NUU, NO SUCH FOLDER! : ShowHide
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


After that please retry if it works now.
[spoiler= YAAAY MY SERVLET WORKS]Fnie. Now bring me cookies!

NUUU *CRY* STILL NOT WORKING [/spoiler: ShowHide

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]
JEP, SEEMS FINE : ShowHide

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/

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:

[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.

NUU, NO SUCH FOLDER! : ShowHide
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


After that please retry if it works now.
[spoiler= YAAAY MY SERVLET WORKS]Fnie. Now bring me cookies!

NUUU *CRY* STILL NOT WORKING [/spoiler: ShowHide

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]
If you see any mistakes, pls tell me
*10000 letters ^.^
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)


DJ Omnimaga


Powered by EzPortal