Apache Tomcat will not start on Mac - java

I cannot get Apache Tomcat to start. I followed the instructions for installing Tomcat on the Mac found at https://www.dev2qa.com/how-to-install-tomcat-in-macos/.
After I type the command to start Tomcat, the response from the command line is that Tomcat has started.
However, when I go to the browser, the default page is not showing up. I further checked to see if the port was being used by using the command
lsof -nP -i4TCP:8080 | grep LISTEN
which showed that no program is using the port. I also read the 'RUNNING.txt' that instructed me on setting the environmental variables, which I did. Any suggestions on why Tomcat is not starting up.
I'm using jdk 1.8.0_202 and Apache Tomcat 9.0.14 that is running of Mac OS High Sierra.

BatChmod
After downloading a fresh version of Tomcat, I use the BatChmod app to alter the file permissions. Tomcat will not launch properly without altering the permissions.
I do not know the command-line equivalent, but here is a screenshot of the settings I have used for years successfully.
Plea for help
If anyone can write the equivalent as a shell script for macOS, please post!
Even better, explain how to wrap such a script as an AppleScript for drag-and-drop execution in Finder.

The problem turned out to be a permissions problem. When I installed Tomcat, I put the folder in the '/Library/Tomcat' directory. Even though the Tomcat files were changed to be executable, the user and group ownership remained the same. To get Tomcat to run, I moved the directory to 'Users/MyUserName/Tomcat'. Once I did that, the default Tomcat page ran.

Related

Keeping a Maven/jetty app running permanently on GCE

I have created a VM instance on Google Cloud Ploutform, Compute engine. Installed Ubunutu 18.04 LTS, Java JDK, Maven and Jetty. Also installed Tomcat, but not using that at the mo.
I set the JAVA_HOME to the JDK location and added it to /etc/enviroment and confirmed this with source /etc/enviroment. Then I CD into my app run mnv jetty:run and the app comes up on port 8888 and everything works great.
Im using the GCE Browser SSH terminal and I have two problems. When I close my laptop or shut the browser the app terminates and goes down. So I have to SSH back into GCE and run the above command but firstly it tells me that my java home is pointing to jre not JDK. Running echo JAVA_HOME shows its correct, so I need to run source /etc/environment before mvn jetty:run each time I log in.
1, How do I make the app stay open so its not reliant on a open terminal on my PC (happy to leave one open and running on the machine just not sure how to do this).
2, Why do I have to run a source each time I log in? Surely having it set in the environment file is enough?
Im a bit of a newb on java and linux so any help/advice appreciated.
Paul
You can run your app in the background so that even if you close the
terminal it will not affect the java process. You can use this
command
$ nohup mvn jetty:run &
You logs will be redirected to a file called nohup.out in the same directory
For setting the env variables there is one file called /etc/profile.
Just mention the details in this file and login/logout, it will be
permanent.

apache tomat7 not starting in browser?

Hi i'm using Apache Tomcat 7,with jdk 1.7 in windows 8. and i have installed tomcat successfully in windows 8,now i'm going hit URL in browser like"localhost:8080" it's work fine,after i open eclipse created web-application & i configured tomcat with that web-application,now i try to restart i'm getting error like!!
so for that,i have stopped tomcat in services(task-manger-service).now it will work fine(it get restarted in eclipse and works fine). when i hit URL in browser like"localhost:8080" i' getting error like ! and more i have added java_home,Catalina_home and also path.
can any one help me out it should work in both eclipse & browser?
First do
netstat -a -b -o
and see if ports that are configured in Eclipse Tomcat are free. If they are not free kill that process
taskkill /PID <pid>
Use /F flag if needed. You should get PID fro, netstat command. You should get Eclipse tomcat ports from Server tab of JavaEE perspective
Then start your tomcat.
PS : If you are getting 404 either you are entering incorrect URL or server is not up in the first place. In any case check the logs if you are getting 404.
Follow the below steps
Right click on your eclipse project
Select Refresh
Click the Run icon
It is not straight forward when you invoke Tomcat from within Eclipse. Please read the FAQ section at https://wiki.eclipse.org/WTP_Tomcat_FAQ
It explains how if you start Tomcat from within Eclipse, the binaries of original directories of Tomcat are used, but the web apps etc are stored separately in the Eclipse Workspace.

How to configure apache tomcat server

I have install jdk1.6.0_04 and I have also install apache-tomcat-8.0.9
and I have set path C:\Program Files (x86)\Java\jdk1.6.0_04\bin;
and CLASSPATH appache tomcat server
C:\Program Files (x86)\apache-tomcat-8.0.9\lib\servlet-api.jar;
but still it's not working properly when i try to open apache tomcat server on web browser
web page is not available
Please guide me the correct way to achieve my objective.
Set JAVA_HOME="C:\Program Files (x86)\Java\jdk1.6.0_04" and CATALINA_HOME="C:\Program Files (x86)\apache-tomcat-8.0.9" than go to %CATALINA_HOME%\bin and run startup.bat
All simple configuration in %CATALINA_HOME%\conf\server.xml
You need jdk1.7 + to run tomcat 8, if you are using jdk1.6, you need tomcat 7-.
See this: http://tomcat.apache.org/whichversion.html
This make me remember back in collage, it took me 2 days to finish jdk/tomcat hello world, :) , what a good time it is.
Just make sure, open a command line, input java --version to check whether you jdk is configured well, and which version it is in use. Just to be sure, in some case you need to re-login or reboot to make your new configured jdk work.
Believe me, if you configured jdk well, you don't need to change anything of the tomcat, just unzip it, and start it, it would work, unless the port 8080 is already taken.
Go to the installation folder of apache tomcat in your case as you said its
C:\Program Files (x86)\apache-tomcat-8.0.9\bin and double click the startup.bat
Then go to web browser and type http://localhost:8080 that should do the work
Set up CATALINE_HOME = your tomcat Location
JAVA_HOME = your java (Version 6 or Seven).
Path = Same JAVA_HOME Java version path til bin.
At final run the startup.bat

My Tomcat is not running it just open and close when I click on tomcat7.exe [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I am installing Tomcat 7 in my PC it works in Eclipse but when I try to open in bin/ tomcat7.exe it just open and closes, (I am stopping the server in Eclipse). Also, in Eclipse I'am trying to open admin console like URL:(localhost:1234/admin) it shows 404 error. Can anyone who knows this problem explain a solution?
If you are using Windows, you can follow the following to run tomcat7.exe :
Open your Command prompt (cmd)
Set your JAVA_HOME or JRE_HOME. Eg. set JRE_HOME=C:\Program Files\Java\jre7
Go to the directory of your tomcat. Eg. cd C:\Program Files\apache-tomcat-7.0.35\bin
Run startup.bat file. Eg. startup.
This should start your tomcat server without using Eclipse.
First Set JAVA_HOME and CLASSPath path
For Windows Java Path Settings
Right click on Computer and open Properties.
In Windows Vista or Windows 7, go to Advanced System Settings.
Else go to next step. Go to Advanced Tab and click on Environment
Variables button.
Select CLASSPath under the list of System Variables, and press Edit and add If CLASSPath not available there click New button add
C:\Program Files\java\jre 1.x.x_xx\bin
after a semicolon.
Now click on New' button under system variables and enter
JAVA_HOME as variable name and path to jdk home directory (ex.
C:\Program Files\Java\jdk1.x.x_xx
After Completing Java Path Settings
Go to the directory of your Tomcat. Eg. cd C:\Program
Files\apache-tomcat-7.0.35\bin
Run startup.bat file
To start your application server in Windows :
Open command prompt .(Run as Administrator).
Go to the path (..\apache-tomcat-8.0.27\bin) and run startup.bat
A new command prompt opens up and should stay unclosed to tell your server is in running state.
If command prompt opens and closes automatically, then the reason can be as below.
tomcat is already in started state in Eclipse.
Check the connector port configured in server.xml file and check if that port is free in your local machine. [netstat command]
Change the connector port to some unused port, preferably in 80XX series.
Let me know if you are able to invoke localhost:(the http connector port) you have configured in server.xml through you web browser.
You don't start Tomcat by double clicking the exe, use the batch files instead.
startup.bat starts the server, shutdown.bat stops it again.
And ignore the advise to get the service installer. You don't need those unless you want the server to start on system boot and run in the background. Which you don't want unless you're going to configure a production server, which you aren't here.
The batch files are in the same directory on your computer as the exe.
you have to set JAVA_HOME and JRE_HOME in System environment.while setting the JAVA_HOME and JRE_HOME, you should assure that JRE path that you are setting is corresponding to the JDK whose path you have set in JAVA_HOME. some time what happens that there may be more than one JDK in the system so conflict occurs. better to have only one JDK and corresponding JRE.
This is probably due to a bad setup of an environment variable.
For example, if you setup incorrect JAVA_OPTS, tomcat startup will fail.
You can check your configuration by calling : catalina configtest
Here an example of the output for bad setup of JAVA_OPTS :
Error occurred during initialization of VM Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
It works for me after updating the jdk path in JAVA_HOME compatible to your tomcat version in user Variables.
the JAVA_HOME and JRE_HOME environment variables set should not have semicolon or ; at the end...I was facing similar problem...removed semi-colon or ; from the end and tomcat server started from cmd screen after running startup command(of tomcat..bin folder).
I checked environment variables and compiler version everything was fine, deleting junk files from work folder worked for me.
Just download the tomcat 32-bit/64-bit Windows Service Installer (pgp, md5) as in this set up is given which will install tomcat on your PC and you can also start and stop tomcat using the tomcat service.
In my experience tomcat7 might not like it if JAVA_PATH or JDK_PATH contain bracket symbols like in "Program Files (x86)". Make sure you format path in your environmental variables correctly or move your JDK to another folder.
In my case, I had some reference to a jar file in catilana.bat, but the jar I had removed from my system. Tomcat started successfully once I removed that reference from catilana.bat
Check your JRE_HOME location in environment variables. if it didn't work then try
1). Open CMD in administration mode.
2). locate to your tomcat directory.
3). run startup.bat --->> It will show your problem.
Had the same problem with Apache Tomcat 9 version.
Solution is very simple.
Apache Tomcat 9 is supported by Java 8 and later versions. So, I had JRE_HOME with JRE7 path, I binded it to new JRE8 and everything works fine.
Different versions of Apache Tomcat are available for different versions of the Servlet and JSP specifications. The mapping between the specifications and the respective Apache Tomcat versions is:

Starting Jetty via launch script does not work

I have a problem with starting Jetty via the startup command /etc/init.d/jetty. When I execute the command the following output is generated:
/etc/init.d/jetty start
Starting Jetty servlet engine.:
Jetty Rotate logs
Jetty servlet engine started, reachable on http://jagadguru:80/.: jetty.
It does start successfully when I type java -jar start.jar in my Jetty directory.
Can anyone help me with this?
This is likely a file permission issue. Even if you are running the start script with sudo, the script defines a jetty user (default is jetty). I had an issue similar to this where my permissions on /tmp prevented jetty from creating a file there. I adjusted the permissions on /tmp and all is well! The jetty user also needs permissions on the jetty folder of course.
Also, for checking if Jetty is finding java correctly, run sudo service jetty check
It's probably an issue due to wrong permissions on some work or log folder. I assume the start script tries to change the user and therefore doesn't has the same permissions as the one you use when running Jetty via "java -jar".
Another possibility is that you don't have JAVA_HOME set and the start script doesn't find your java bin.
Please attach some kind of log file as it is really hard to say more without more detailed information.
As answered here, the default configuration for Jetty in /etc/default/jetty only allows connections from localhost, you need to set JETTY_HOST to 0.0.0.0 to allow Jetty to accept connections from any host.
Add the following line to /etc/default/jetty:
JETTY_HOST 0.0.0.0

Categories