I was trying to learn how to use servlet by following the tutorial in this page:
https://www.ntu.edu.sg/home/ehchua/programming/howto/Tomcat_HowTo.html
When I reached 2.6 STEP 5: Develop and Deploy a WebApp, I was told to restart tomcat so that it'll load the directory I just made. However, the changes I made was not loaded, the assigned port is still 8080 even though I assigned it to 9999 and the hello directory was not found. Here are the messages when I issued startup.bat:
Apr 26, 2019 5:32:04 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.2.21 using APR version 1.6.5.
Apr 26, 2019 5:32:04 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Apr 26, 2019 5:32:04 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.1.1a 20 Nov 2018)
Apr 26, 2019 5:32:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Apr 26, 2019 5:32:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Apr 26, 2019 5:32:04 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 494 ms
Apr 26, 2019 5:32:04 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 26, 2019 5:32:04 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Apr 26, 2019 5:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory G:\Tomcat 2\webapps\docs
Apr 26, 2019 5:32:05 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [146] milliseconds.
Apr 26, 2019 5:32:05 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory G:\Tomcat 2\webapps\examples
Apr 26, 2019 5:32:05 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory G:\Tomcat 2\webapps\host-manager
Apr 26, 2019 5:32:05 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory G:\Tomcat 2\webapps\manager
Apr 26, 2019 5:32:05 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory G:\Tomcat 2\webapps\ROOT
Apr 26, 2019 5:32:05 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Apr 26, 2019 5:32:05 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Apr 26, 2019 5:32:05 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1092 ms
As you can see, the hello directory was not deployed. So, what is exactly happening here?
I just realized that when I issued the startup & shutdown command that there was an information in the console which looked like this:
Using CLASSPATH: "G:\Learning\tomcat9\bin\bootstrap.jar;G:\Learning\tomcat9\bin\tomcat-juli.jar"
It seemed that my classpath was pointing to the wrong path. I deleted CATALINA_HOME in the environment variable settings, and now it is working fine.
Related
I have a simple maven spring project, when I run the project on the tomcat server, I don't see tomcat load the configuration on the start up.
MySpringMvcDispatcherServletInitializer.java
package com.abc.xyz.config;
import
org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class MySpringMvcDispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
#Override
protected Class<?>[] getRootConfigClasses() {
// TODO Auto-generated method stub
return null;
}
#Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { DemoAppConfig.class };
}
#Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
DemoAppConfig.java
package com.abc.xyz.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
#Configuration
#EnableWebMvc
#ComponentScan("com.abc.xyz")
public class DemoAppConfig implements WebMvcConfigurer {
}
DemoRestController.java
package com.abc.xyz.rest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
#RequestMapping("/test")
public class DemoRestController {
// add code for the "/hello" endpoint
#GetMapping("/hello")
public String sayHello() {
return "Hello World!";
}
}
tomcat7 startup log
Oct 24, 2018 4:15:45 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:spring-rest-demo' did not find a matching property.
Oct 24, 2018 4:15:45 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SIT_Dashboard' did not find a matching property.
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Sep 29 2017 12:23:15 UTC
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 7.0.82.0
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 7
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.1
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\FAST\JDK64\LINKS\JDK8\jre
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_144-b01
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\wtpwebapps
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\endorsed
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Oct 24, 2018 4:15:45 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\FAST\JDK64\LINKS\JDK8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\FAST\JDK64\1.8.0.144\bin;C:\ProgramData\Oracle\Java\javapath;C:\oracle\product\11.2.0\client_64\BIN\;C:\Program Files\Micro Focus\Reflection\;C:\Program Files (x86)\Micro Focus\Reflection\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\1E\SMSNomad\;C:\Program Files\aim\aim-install\bin\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Git\cmd;C:\FAST\nodejs\6.11.4\;C:\Program Files\TortoiseSVN\bin;C:\opt\gate\base91\..\perl\bin;C:\Users\R633368\AppData\Roaming\npm;C:\FAST\maven\3.5.0\apache-maven-3.5.0\bin;.
Oct 24, 2018 4:15:45 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Oct 24, 2018 4:15:45 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 768 ms
Oct 24, 2018 4:15:45 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 24, 2018 4:15:45 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.82
Oct 24, 2018 4:15:46 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [472] milliseconds.
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\docs
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\docs has finished in 101 ms
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\examples
Oct 24, 2018 4:15:47 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Oct 24, 2018 4:15:47 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Oct 24, 2018 4:15:47 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache#6d4352bf')
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\examples has finished in 499 ms
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\host-manager
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\host-manager has finished in 157 ms
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\manager
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\manager has finished in 82 ms
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\ROOT
Oct 24, 2018 4:15:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\ROOT has finished in 77 ms
Oct 24, 2018 4:15:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Oct 24, 2018 4:15:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 24, 2018 4:15:48 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2191 ms
As you can see, the start up doesn't show it read my spring configuration, please help, thanks in advance
tomcat web application manager
Updated: I have a temp fix, (wow,it takes me 2 days to make some progress since there is no ERRORs at all in the project).
Here is the trick: Right click project => properties=> Deployment
Assembly=> add=> choose Java Build Path Entries=>choose Maven
Dependencies=> apply=> OK
You can see server log refresh and it finally loads spring
configuration, and if you check
tomcat home directory/wtpwebapps/{project name}/WEB-INF/lib, you can
see all the maven dependencies are copied to here
Up to this point, It looks like everything is fine now, but I find the
other issue, every time I right click=>maven=> update project...=> it
will try to remove the dependencies(jars) in tomcat home
directory/wtpwebapps/{project name}/WEB-INF/lib,
If your project is running at the tomcat , you will get a error
because these jars are being used.
But if you stop server, and update project and then run as server
again, everything is back to normal, no error, no spring configuration
in the server startup log, then you have to do the same trick again.
I tried so many online solutions about "maven project update will
remove jars in tomcat server", none of them are working. So if anyone
has the the fix, please shared
getting below error when deploying war to openshift using git command..i was able to deploy correctly earlier but not sure what happened and now not able to deploy and getting this error..in local i am able to run the same wat correctly.
Sep 25, 2014 12:59:53 PM org.apache.catalina.startup.Catalina addClusterRuleSet
INFO: Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
Sep 25, 2014 12:59:53 PM org.apache.catalina.startup.Catalina addClusterRuleSetINFO: Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.ap
ache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
Sep 25, 2014 12:59:54 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /opt/rh/mysql55/root/usr/lib64:/usr/java/packages/lib/i386:/lib:/usr/lib
Sep 25, 2014 12:59:55 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-127.3.114.129-8080"]
Sep 25, 2014 12:59:55 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2841 ms
Sep 25, 2014 12:59:56 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 25, 2014 12:59:56 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Sep 25, 2014 12:59:56 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/openshift/53579b125004465e18000995/app-root/runtime/dependencies/jbossews/webapps/abc.war
Sep 25, 2014 1:00:56 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Sep 25, 2014 1:00:56 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
Sep 25, 2014 1:00:56 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/53579b125004465e18000995/app-root/runtime/dependencies/jbossews/webapps/ROOT.war has finished in
8,534 ms
Sep 25, 2014 1:00:56 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.3.114.129-8080"]
Sep 25, 2014 1:00:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 60436 ms
Looks like an exception is being thrown from your application. Is this the catalina.out log? How are you deploying the application (via IDE or?).
I started tomcat 7 using,
cd /opt/tomcat7/bin
$/opt/tomcat7/bin ./startup.sh
It shows process running
root 23206 130 3.4 1323956 572880 pts/2 Sl 07:58 1:05 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dspring.profiles.active=mongo1,maxListenersAllowed -DST_SERVER=mongo1 -Djava.endorsed.dirs=/opt/tomcat7/endorsed -classpath /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat7 -Dcatalina.home=/opt/tomcat7 -Djava.io.tmpdir=/opt/tomcat7/temp org.apache.catalina.startup.Bootstrap start
If I shutdown it using
$/opt/tomcat7/bin ./shutdown.sh
It gives this message
Using CATALINA_BASE: /opt/tomcat7
Using CATALINA_HOME: /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar
but if I check the above process, it still shows it running. Tomcat doesn't shut down. I tried it using root user as well but still no success.
Manully I can kill the process but I want to create deploy script so want to do it using shutdown.sh and startup.sh
Same happens if I try using
/opt/tomcat7/bin/catalina.sh start
/opt/tomcat7/bin/catalina.sh stop
Log
Jul 23, 2014 8:26:17 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 361 ms
Jul 23, 2014 8:26:18 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 23, 2014 8:26:18 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/docs
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/manager
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/ROOT
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/examples
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/host-manager
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/target
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 862 ms
Jul 23, 2014 8:26:42 AM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:42 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
You can force the shutdown by PID.
Edit
..tomcat/bin/catalina.sh
and set the
CATALINA_PID=path
variable to a local path.
CATALINA_PID
(Optional) Path of the file which should contains the pid of the
catalina startup java process, when start (fork) is used
then you can shutdown Tomcat with -force flag
../tomcat/bin/shutdown.sh -force
If the script can not stop Tomcat normally will use a kill to stop the process by PID.
Update:
According to Joshua Taylor comment, the recommended way to store additional variables for running tomcat is the setenv.* script.
Take a look at (3.4) Using the "setenv" script (optional, recommended) section in the tomcat running docs
https://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt
If you are in windows, and using the portable tomcat, you can use the nircmd program tool, and close by title console window, instead of stopping by PID.
When you have downloaded this tool, just do:
nircmd.exe win close title "Tomcat"
I once had the misfortune of a page running infinite redirect loops due to a faulty authentication mechanism.
It eventually slowed down the entire server, but also made it impossible for me to shut it down gracefully. In the end I had to employ brute force like vzamanillo describes.
The point being that something fishy might be running within your server's processes that won't finish properly.
Is you shutdown port set? (in /etc/tomcat9/conf/server.xml )
<Server port="9005" shutdown="SHUTDOWN">
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I want to deploy it with the .war file generated by netbeans in Windows, my project is a web app, and I want to run in in LINUX (LUBUNTU), but I can't start it. I'm using the manager-gui.
Please help me with this error. I'm new in linux.
Sep 18, 2013 12:01:45 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Sep 18, 2013 12:01:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 18, 2013 12:01:47 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 18, 2013 12:01:47 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3021 ms
Sep 18, 2013 12:01:47 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 18, 2013 12:01:47 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.42
Sep 18, 2013 12:01:47 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/tomcat/apache-tomcat-7.0.42/webapps/Healthlink.war
Sep 18, 2013 12:01:52 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Sep 18, 2013 12:01:52 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [147] milliseconds.
Sep 18, 2013 12:01:52 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Healthlink] startup failed due to previous errors
Sep 18, 2013 12:01:52 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/Healthlink] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 18, 2013 12:01:53 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/host-manager
Sep 18, 2013 12:01:53 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/ROOT
Sep 18, 2013 12:01:53 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/examples
Sep 18, 2013 12:01:53 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/docs
Sep 18, 2013 12:01:54 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/manager
Sep 18, 2013 12:01:54 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 18, 2013 12:01:54 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 18, 2013 12:01:54 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 7183 ms
Sep 18, 2013 12:03:32 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Sep 18, 2013 12:03:34 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 18, 2013 12:03:34 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 18, 2013 12:03:34 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 4193 ms
Sep 18, 2013 12:03:35 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 18, 2013 12:03:35 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.42
Sep 18, 2013 12:03:35 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/tomcat/apache-tomcat-7.0.42/webapps/Healthlink.war
Sep 18, 2013 12:03:40 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Sep 18, 2013 12:03:51 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [10,839] milliseconds.
Sep 18, 2013 12:03:51 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Healthlink] startup failed due to previous errors
Sep 18, 2013 12:03:51 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/Healthlink] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 18, 2013 12:03:51 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/host-manager
Sep 18, 2013 12:03:51 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/ROOT
Sep 18, 2013 12:03:52 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/examples
Sep 18, 2013 12:03:52 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/docs
Sep 18, 2013 12:03:52 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/manager
Sep 18, 2013 12:03:52 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 18, 2013 12:03:52 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 18, 2013 12:03:52 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 17665 ms
Sep 18, 2013 12:04:09 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Sep 18, 2013 12:04:09 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Healthlink] startup failed due to previous errors
Sep 18, 2013 12:04:09 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/Healthlink] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 18, 2013 12:06:33 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Sep 18, 2013 12:06:36 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 18, 2013 12:06:36 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 18, 2013 12:06:36 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 5065 ms
Sep 18, 2013 12:06:36 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 18, 2013 12:06:36 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.42
Sep 18, 2013 12:06:36 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/tomcat/apache-tomcat-7.0.42/webapps/Healthlink.war
Sep 18, 2013 12:06:42 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Sep 18, 2013 12:06:42 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Healthlink] startup failed due to previous errors
Sep 18, 2013 12:06:42 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/Healthlink] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 18, 2013 12:06:42 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/host-manager
Sep 18, 2013 12:06:42 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/ROOT
Sep 18, 2013 12:06:43 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/examples
Sep 18, 2013 12:06:43 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/docs
Sep 18, 2013 12:06:43 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/tomcat/apache-tomcat-7.0.42/webapps/manager
Sep 18, 2013 12:06:43 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 18, 2013 12:06:43 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 18, 2013 12:06:43 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 7305 ms
Here's the most important line of your overzealously long (and repeated) log:
SEVERE: Error listenerStart
This basically means that a ServletContextListener implementation which is registered by either a #WebListener annotation on the class or a <listener> entry in web.xml has thrown an unhandled exception inside the contextInitialized() method. This is usually caused by a developer's mistake (a bug) and needs to be fixed. For example, a NullPointerException.
If you can't figure the cause by just staring at or unit-testing the code inside contextInitialized() method, then you'd need to create a logging.properties file in project's src folder (there where you have your Java classes; it should at least ultimately end up in /WEB-INF/classes folder of the built WAR) with the following contents:
org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler
This will tell Tomcat to log exceptions during starting of listeners (and filters) to the console.
I am trying to start tomcat using cargo api. Everything looks fine from the logs, but when i hit the url(http://localhost:8079/), the tomcat management page is not coming up.
Update: I tried starting tomcat from eclipse. The logs say the exact same thing but i am not able to see the management console. so its not an issue with cargo for sure. I get a 404 when i start the server from eclipse .
the code is this
LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory().createConfiguration(
"tomcat6x", ContainerType.INSTALLED, ConfigurationType.STANDALONE);
InstalledLocalContainer container =
(InstalledLocalContainer) new DefaultContainerFactory().createContainer(
"tomcat6x", ContainerType.INSTALLED, configuration);
//container.setHome(installer.getHome());
//container.setHome("C:\\Users\\Kriss\\AppData\\Local\\Temp\\cargo\\installs\\apache-tomcat-7.0.25\\apache-tomcat-7.0.25");
container.setHome("C:\\TOSCA\\apache-tomcat-7.0.25-windows-x86\\apache-tomcat-7.0.25\\");
container.setOutput("C:\\TOSCA\\output.log");
//getting cargo related logging
container.setLogger(fileLogger);
//changing the log settings of the container
// configuration.setProperty(GeneralPropertySet.LOGGING, LoggingLevel.HIGH.getLevel());
configuration.setProperty("cargo.servlet.port", "8079");
logger.info(container.getOutput());
container.setAppend(false);
logger.info("gethome value is" + container.getHome());
// (3) Statically deploy some WAR (optional)
// configuration.addDeployable(new WAR("cargo.war"));
// (4) Start the container
container.start();
logger.info("Container is started");
Thread.sleep(26000);
container.stop();
logger.info("Container is stopped");
The logs look fine(atleast to me :P)
Apr 10, 2012 4:27:54 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [C:\Users\Kriss\AppData\Local\Temp\cargo\conf\common\classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 10, 2012 4:27:54 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [C:\Users\Kriss\AppData\Local\Temp\cargo\conf\common\lib], exists: [false], isDirectory: [false], canRead: [false]
Apr 10, 2012 4:27:54 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [C:\Users\Kriss\AppData\Local\Temp\cargo\conf\shared\classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 10, 2012 4:27:54 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [C:\Users\Kriss\AppData\Local\Temp\cargo\conf\shared\lib], exists: [false], isDirectory: [false], canRead: [false]
Apr 10, 2012 4:27:55 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter\Driver;C:\Program Files\Java\jdk1.7.0_01\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;.
Apr 10, 2012 4:27:55 PM org.apache.catalina.startup.SetAllPropertiesRule begin
WARNING: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'emptySessionPath' to 'true' did not find a matching property.
Apr 10, 2012 4:27:55 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8079"]
Apr 10, 2012 4:27:55 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Apr 10, 2012 4:27:55 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 674 ms
Apr 10, 2012 4:27:55 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 10, 2012 4:27:55 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Apr 10, 2012 4:27:55 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\Users\Kriss\AppData\Local\Temp\cargo\conf\conf\Catalina\localhost\manager.xml
Apr 10, 2012 4:27:56 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\Users\Kriss\AppData\Local\Temp\cargo\conf\webapps\cargocpc.war
Apr 10, 2012 4:27:56 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Users\Kriss\AppData\Local\Temp\cargo\conf\webapps\host-manager
Apr 10, 2012 4:27:56 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8079"]
Apr 10, 2012 4:27:56 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Apr 10, 2012 4:27:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 610 ms
Minor detail: when i tried to start, bootstrap was missing some classes which were part of tomcat-juli.jar. so i unjarred that and put the classes inside bootstrap.jar. I just thought i should mention that as a side comment though i dont think it is causing some problem..
Also here is the log when i start tomcat using command prompt:
Apr 09, 2012 1:55:36 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.22.
Apr 09, 2012 1:55:36 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [false], sendfile [true], accept filters [false], r
andom [true].
Apr 09, 2012 1:55:37 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Apr 09, 2012 1:55:37 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Apr 09, 2012 1:55:37 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1944 ms
Apr 09, 2012 1:55:37 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 09, 2012 1:55:37 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Apr 09, 2012 1:55:37 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\docs
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\examples
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\host-manager
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\manager
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\TOSCA\apache-tomcat-7.0.25-windows-
x86\apache-tomcat-7.0.25\webapps\ROOT
Apr 09, 2012 1:55:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Apr 09, 2012 1:55:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Apr 09, 2012 1:55:38 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 927 ms