Showing posts with label tomcat. Show all posts
Showing posts with label tomcat. Show all posts

Changing Tomcat default web application

Add below line in server.xml in Host entry for localhost in server.xml.

<Context path="" docBase="whatsapp-direct" />


Result:


<Host name="localhost">

                <!-- SingleSignOn valve, share authentication between web applications 
                    Documentation at: /docs/config/valve.html -->
                <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" 
                    /> -->

                <!-- Access log processes all example. Documentation at: /docs/config/valve.html 
                    Note: The pattern used is equivalent to using pattern="common" -->
                <Valve className="org.apache.catalina.valves.AccessLogValve"
                    directory="logs" prefix="localhost_access_log." suffix=".txt"
                    pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false" />

                <Context path="" docBase="/usr/local/tomcat/mywebapps/myapplication">
                    <WatchedResource>WEB-INF/web.xml</WatchedResource>
                </Context>

            </Host>

Context path when the war deployed to tomcat

Most of the times, the name of the war file acts as the context path.

The Context path attribute is ignored unless the path is specified in a hard-coded Context in server.xml, which is strongly discouraged, and doesn't take multilevel paths.
The name of the war file, or the name of the Context xml file in tomcat/conf/Catalina/hostnamebecomes the path of the deployed application.
In your case the latter of the two above is the solution, just make sure you put the .war file outside of the designated appBase for the Host, or you'll deploy the app twice.
In: conf/Catalina/localhost/myapp#path.xml
<?xml version="1.0"?>
<Context docBase="/some/path/to/myapp.war">
</Context>

How to change tomcat port number from 8080

  • Goto tomcat>conf folder
  • Edit server.xml
  • Search "Connector port"
  • Replace "8080" (Default) by your new port number
  • Restart tomcat server.
Similarly you can also change port number for HTTPS as well.

DEBUGGING THE DREADED “SEVERE: ERROR LISTENERSTART” AND “SEVERE: ERROR FILTERSTART” TOMCAT ERROR MESSAGES



|
Just a quick post that I hope might benefit others. If you have been developing web applications on tomcat for a while you have likely come the two error messages mentioned in the title.

SEVERE: Error listenerStart

Occurs when an exception is thrown in the contextInitialized method of a ServletContextListener

SEVERE: Error filterStart

Occurs when an exception is thrown in the init method of a Filter
Unfortunately by default, tomcat won’t provide you with any details about the cause of the error. Infact it wont even tell you which filter or listener is failing. This can be big problem in applications of significant size that have many filters and listeners configured. Fortunately there is a solution. In your webapplication’s WEB-INF/classes folder you can create a logging.properties file with the following contents
org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler
Now you will be presented with the stacktrace

Reference: http://blog.trifork.com/2011/03/18/debugging-the-dreaded-severe-error-listenerstart-and-severe-error-filterstart-tomcat-error-messages/