Package org.apache.catalina.manager
Class ManagerServlet
- java.lang.Object
-
- jakarta.servlet.GenericServlet
-
- jakarta.servlet.http.HttpServlet
-
- org.apache.catalina.manager.ManagerServlet
-
- All Implemented Interfaces:
Servlet
,ServletConfig
,java.io.Serializable
,ContainerServlet
- Direct Known Subclasses:
HTMLManagerServlet
public class ManagerServlet extends HttpServlet implements ContainerServlet
Servlet that enables remote management of the web applications installed within the same virtual host as this web application is. Normally, this functionality will be protected by a security constraint in the web application deployment descriptor. However, this requirement can be relaxed during testing.This servlet examines the value returned by
getPathInfo()
and related query parameters to determine what action is being requested. The following actions and parameters (starting after the servlet path) are supported:- /deploy?config={config-url} - Install and start a new
web application, based on the contents of the context configuration
file found at the specified URL. The
docBase
attribute of the context configuration file is used to locate the actual WAR or directory containing the application. - /deploy?config={config-url}&war={war-url}/ - Install and start
a new web application, based on the contents of the context
configuration file found at
{config-url}
, overriding thedocBase
attribute with the contents of the web application archive found at{war-url}
. - /deploy?path=/xxx&war={war-url} - Install and start a new
web application attached to context path
/xxx
, based on the contents of the web application archive found at the specified URL. - /list - List the context paths of all currently installed web
applications for this virtual host. Each context will be listed with
the following format
path:status:sessions
. Where path is the context path. Status is either running or stopped. Sessions is the number of active Sessions. - /reload?path=/xxx - Reload the Java classes and resources for the application at the specified path.
- /resources?type=xxxx - Enumerate the available global JNDI resources, optionally limited to those of the specified type (fully qualified Java class name), if available.
- /serverinfo - Display system OS and JVM properties.
- /sessions - Deprecated. Use expire.
- /expire?path=/xxx - List session idle time information about the
web application attached to context path
/xxx
for this virtual host. - /expire?path=/xxx&idle=mm - Expire sessions
for the context path
/xxx
which were idle for at least mm minutes. - /sslConnectorCiphers - Display diagnostic info on SSL/TLS ciphers that are currently configured for each connector.
- /start?path=/xxx - Start the web application attached to
context path
/xxx
for this virtual host. - /stop?path=/xxx - Stop the web application attached to
context path
/xxx
for this virtual host. - /threaddump - Write a JVM thread dump.
- /undeploy?path=/xxx - Shutdown and remove the web application
attached to context path
/xxx
for this virtual host, and remove the underlying WAR file or document base directory. (NOTE - This is only allowed if the WAR file or document base is stored in theappBase
directory of this host, typically as a result of being placed there via the/deploy
command. - /vminfo - Write some VM info.
- /save - Save the current server configuration to server.xml
- /save?path=/xxx - Save the context configuration for the web
application deployed with path
/xxx
to an appropriately named context.xml file in thexmlBase
for the associated Host.
Use
path=/
for the ROOT context.The syntax of the URL for a web application archive must conform to one of the following patterns to be successfully deployed:
- file:/absolute/path/to/a/directory - You can specify the absolute path of a directory that contains the unpacked version of a web application. This directory will be attached to the context path you specify without any changes.
NOTE - Attempting to reload or remove the application containing this servlet itself will not succeed. Therefore, this servlet should generally be deployed as a separate web application within the virtual host to be managed.
The following servlet initialization parameters are recognized:
- debug - The debugging detail level that controls the amount of information that is logged by this servlet. Default is zero.
- Author:
- Craig R. McClanahan, Remy Maucherat
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.File
configBase
Path where context descriptors should be deployed.protected Context
context
The Context container associated with our web application.protected int
debug
The debugging detail level for this servlet.protected javax.naming.Context
global
The global JNDINamingContext
for this server, if available.protected Host
host
The associated host.protected javax.management.MBeanServer
mBeanServer
MBean server.protected javax.management.ObjectName
oname
The associated deployer ObjectName.protected static StringManager
sm
The string manager for this package.protected java.io.File
versioned
Path used to store revisions of webapps.protected Wrapper
wrapper
The Wrapper container associated with this servlet.
-
Constructor Summary
Constructors Constructor Description ManagerServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addServiced(java.lang.String name)
Deprecated.Unused.protected void
check(java.lang.String name)
Invoke the check method on the deployer.protected void
deploy(java.io.PrintWriter writer, java.lang.String config, ContextName cn, java.lang.String tag, boolean update, HttpServletRequest request, StringManager smClient)
Deploy a web application archive (included in the current request) at the specified context path.protected void
deploy(java.io.PrintWriter writer, java.lang.String config, ContextName cn, java.lang.String war, boolean update, StringManager smClient)
Install an application for the specified path from the specified web application archive.protected void
deploy(java.io.PrintWriter writer, ContextName cn, java.lang.String tag, StringManager smClient)
Install an application for the specified path from the specified web application archive.void
destroy()
Finalize this servlet.void
doGet(HttpServletRequest request, HttpServletResponse response)
Process a GET request for the specified resource.void
doPut(HttpServletRequest request, HttpServletResponse response)
Process a PUT request for the specified resource.protected void
expireSessions(java.io.PrintWriter writer, ContextName cn, HttpServletRequest req, StringManager smClient)
Extract the expiration request parameterprotected void
findleaks(boolean statusLine, java.io.PrintWriter writer, StringManager smClient)
Find potential memory leaks caused by web application reload.protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getConnectorCerts(StringManager smClient)
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getConnectorCiphers(StringManager smClient)
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getConnectorTrustedCerts(StringManager smClient)
Wrapper
getWrapper()
Return the Wrapper with which we are associated.void
init()
Initialize this servlet.protected boolean
isDeployed(java.lang.String name)
Invoke the isDeployed method on the deployer.protected boolean
isServiced(java.lang.String name)
Deprecated.Unused.protected void
list(java.io.PrintWriter writer, StringManager smClient)
Render a list of the currently active Contexts in our virtual host.protected void
printResources(java.io.PrintWriter writer, java.lang.String prefix, javax.naming.Context namingContext, java.lang.String type, StringManager smClient)
List the resources of the given context.protected void
reload(java.io.PrintWriter writer, ContextName cn, StringManager smClient)
Reload the web application at the specified context path.protected void
removeServiced(java.lang.String name)
Invoke the removeServiced method on the deployer.protected void
resources(java.io.PrintWriter writer, java.lang.String type, StringManager smClient)
Render a list of available global JNDI resources.protected void
save(java.io.PrintWriter writer, java.lang.String path, StringManager smClient)
Store server configuration.protected void
serverinfo(java.io.PrintWriter writer, StringManager smClient)
Writes System OS and JVM properties.protected void
sessions(java.io.PrintWriter writer, ContextName cn, int idle, StringManager smClient)
Session information for the web application at the specified context path.void
setWrapper(Wrapper wrapper)
Set the Wrapper with which we are associated.protected void
sslConnectorCiphers(java.io.PrintWriter writer, StringManager smClient)
protected void
sslReload(java.io.PrintWriter writer, java.lang.String tlsHostName, StringManager smClient)
protected void
start(java.io.PrintWriter writer, ContextName cn, StringManager smClient)
Start the web application at the specified context path.protected void
stop(java.io.PrintWriter writer, ContextName cn, StringManager smClient)
Stop the web application at the specified context path.protected void
threadDump(java.io.PrintWriter writer, StringManager smClient, java.util.Enumeration<java.util.Locale> requestedLocales)
Write a JVM thread dump.protected boolean
tryAddServiced(java.lang.String name)
Attempt to mark a context as being servicedprotected void
undeploy(java.io.PrintWriter writer, ContextName cn, StringManager smClient)
Undeploy the web application at the specified context path.protected void
uploadWar(java.io.PrintWriter writer, HttpServletRequest request, java.io.File war, StringManager smClient)
Upload the WAR file included in this request, and store it at the specified file location.protected static boolean
validateContextName(ContextName cn, java.io.PrintWriter writer, StringManager smClient)
protected void
vmInfo(java.io.PrintWriter writer, StringManager smClient, java.util.Enumeration<java.util.Locale> requestedLocales)
Write some VM info.-
Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doTrace, getLastModified, service, service
-
Methods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
-
-
-
Field Detail
-
configBase
protected java.io.File configBase
Path where context descriptors should be deployed.
-
context
protected transient Context context
The Context container associated with our web application.
-
debug
protected int debug
The debugging detail level for this servlet.
-
versioned
protected java.io.File versioned
Path used to store revisions of webapps.
-
host
protected transient Host host
The associated host.
-
mBeanServer
protected transient javax.management.MBeanServer mBeanServer
MBean server.
-
oname
protected javax.management.ObjectName oname
The associated deployer ObjectName.
-
global
protected transient javax.naming.Context global
The global JNDINamingContext
for this server, if available.
-
sm
protected static final StringManager sm
The string manager for this package.
-
wrapper
protected transient Wrapper wrapper
The Wrapper container associated with this servlet.
-
-
Method Detail
-
getWrapper
public Wrapper getWrapper()
Return the Wrapper with which we are associated.- Specified by:
getWrapper
in interfaceContainerServlet
- Returns:
- The Wrapper with which this Servlet is associated.
-
setWrapper
public void setWrapper(Wrapper wrapper)
Set the Wrapper with which we are associated.- Specified by:
setWrapper
in interfaceContainerServlet
- Parameters:
wrapper
- The new wrapper
-
destroy
public void destroy()
Finalize this servlet.- Specified by:
destroy
in interfaceServlet
- Overrides:
destroy
in classGenericServlet
-
doGet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException
Process a GET request for the specified resource.- Overrides:
doGet
in classHttpServlet
- Parameters:
request
- The servlet request we are processingresponse
- The servlet response we are creating- Throws:
java.io.IOException
- if an input/output error occursServletException
- if a servlet-specified error occurs- See Also:
ServletResponse.setContentType(java.lang.String)
-
doPut
public void doPut(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException
Process a PUT request for the specified resource.- Overrides:
doPut
in classHttpServlet
- Parameters:
request
- The servlet request we are processingresponse
- The servlet response we are creating- Throws:
java.io.IOException
- if an input/output error occursServletException
- if a servlet-specified error occurs
-
init
public void init() throws ServletException
Initialize this servlet.- Overrides:
init
in classGenericServlet
- Throws:
ServletException
- if an exception occurs that interrupts the servlet's normal operation
-
findleaks
protected void findleaks(boolean statusLine, java.io.PrintWriter writer, StringManager smClient)
Find potential memory leaks caused by web application reload.- Parameters:
statusLine
- Print a status linewriter
- The output writersmClient
- StringManager for the client's locale
-
sslReload
protected void sslReload(java.io.PrintWriter writer, java.lang.String tlsHostName, StringManager smClient)
-
vmInfo
protected void vmInfo(java.io.PrintWriter writer, StringManager smClient, java.util.Enumeration<java.util.Locale> requestedLocales)
Write some VM info.- Parameters:
writer
- The output writersmClient
- StringManager for the client's localerequestedLocales
- the client's locales
-
threadDump
protected void threadDump(java.io.PrintWriter writer, StringManager smClient, java.util.Enumeration<java.util.Locale> requestedLocales)
Write a JVM thread dump.- Parameters:
writer
- The output writersmClient
- StringManager for the client's localerequestedLocales
- the client's locales
-
sslConnectorCiphers
protected void sslConnectorCiphers(java.io.PrintWriter writer, StringManager smClient)
-
save
protected void save(java.io.PrintWriter writer, java.lang.String path, StringManager smClient)
Store server configuration.- Parameters:
writer
- Destination for any user message(s) during this operationpath
- Optional context path to savesmClient
- i18n support for current client's locale
-
deploy
protected void deploy(java.io.PrintWriter writer, java.lang.String config, ContextName cn, java.lang.String tag, boolean update, HttpServletRequest request, StringManager smClient)
Deploy a web application archive (included in the current request) at the specified context path.- Parameters:
writer
- Writer to render results toconfig
- URL of the context configuration file to be installedcn
- Name of the application to be installedtag
- Tag to be associated with the webappupdate
- Flag that indicates that any existing app should be replacedrequest
- Servlet request we are processingsmClient
- i18n messages using the locale of the client
-
deploy
protected void deploy(java.io.PrintWriter writer, ContextName cn, java.lang.String tag, StringManager smClient)
Install an application for the specified path from the specified web application archive.- Parameters:
writer
- Writer to render results totag
- Revision tag to deploy fromcn
- Name of the application to be installedsmClient
- i18n messages using the locale of the client
-
deploy
protected void deploy(java.io.PrintWriter writer, java.lang.String config, ContextName cn, java.lang.String war, boolean update, StringManager smClient)
Install an application for the specified path from the specified web application archive.- Parameters:
writer
- Writer to render results toconfig
- URL of the context configuration file to be installedcn
- Name of the application to be installedwar
- URL of the web application archive to be installedupdate
- true to override any existing webapp on the pathsmClient
- i18n messages using the locale of the client
-
list
protected void list(java.io.PrintWriter writer, StringManager smClient)
Render a list of the currently active Contexts in our virtual host.- Parameters:
writer
- Writer to render tosmClient
- i18n support for current client's locale
-
reload
protected void reload(java.io.PrintWriter writer, ContextName cn, StringManager smClient)
Reload the web application at the specified context path.- Parameters:
writer
- Writer to render tocn
- Name of the application to be restartedsmClient
- i18n support for current client's locale
-
resources
protected void resources(java.io.PrintWriter writer, java.lang.String type, StringManager smClient)
Render a list of available global JNDI resources.- Parameters:
writer
- Writer to render totype
- Fully qualified class name of the resource type of interest, ornull
to list resources of all typessmClient
- i18n support for current client's locale
-
printResources
protected void printResources(java.io.PrintWriter writer, java.lang.String prefix, javax.naming.Context namingContext, java.lang.String type, StringManager smClient)
List the resources of the given context.- Parameters:
writer
- Writer to render toprefix
- Path for recursionnamingContext
- The naming context for lookupstype
- Fully qualified class name of the resource type of interest, ornull
to list resources of all typessmClient
- i18n support for current client's locale
-
serverinfo
protected void serverinfo(java.io.PrintWriter writer, StringManager smClient)
Writes System OS and JVM properties.- Parameters:
writer
- Writer to render tosmClient
- i18n support for current client's locale
-
sessions
protected void sessions(java.io.PrintWriter writer, ContextName cn, int idle, StringManager smClient)
Session information for the web application at the specified context path. Displays a profile of session thisAccessedTime listing number of sessions for each 10 minute interval up to 10 hours.- Parameters:
writer
- Writer to render tocn
- Name of the application to list session information foridle
- Expire all sessions with idle time > idle for this contextsmClient
- i18n support for current client's locale
-
expireSessions
protected void expireSessions(java.io.PrintWriter writer, ContextName cn, HttpServletRequest req, StringManager smClient)
Extract the expiration request parameter- Parameters:
writer
- Writer to render tocn
- Name of the application to list session information forreq
- The Servlet requestsmClient
- i18n support for current client's locale
-
start
protected void start(java.io.PrintWriter writer, ContextName cn, StringManager smClient)
Start the web application at the specified context path.- Parameters:
writer
- Writer to render tocn
- Name of the application to be startedsmClient
- i18n support for current client's locale
-
stop
protected void stop(java.io.PrintWriter writer, ContextName cn, StringManager smClient)
Stop the web application at the specified context path.- Parameters:
writer
- Writer to render tocn
- Name of the application to be stoppedsmClient
- i18n support for current client's locale
-
undeploy
protected void undeploy(java.io.PrintWriter writer, ContextName cn, StringManager smClient)
Undeploy the web application at the specified context path.- Parameters:
writer
- Writer to render tocn
- Name of the application to be removedsmClient
- i18n support for current client's locale
-
isDeployed
protected boolean isDeployed(java.lang.String name) throws java.lang.Exception
Invoke the isDeployed method on the deployer.- Parameters:
name
- The webapp name- Returns:
true
if a webapp with that name is deployed- Throws:
java.lang.Exception
- Propagate JMX invocation error
-
check
protected void check(java.lang.String name) throws java.lang.Exception
Invoke the check method on the deployer.- Parameters:
name
- The webapp name- Throws:
java.lang.Exception
- Propagate JMX invocation error
-
isServiced
@Deprecated protected boolean isServiced(java.lang.String name) throws java.lang.Exception
Deprecated.Unused. Will be removed in Tomcat 10.1.x onwards.Invoke the isServiced method on the deployer.- Parameters:
name
- The webapp name- Returns:
true
if a webapp with that name is being serviced- Throws:
java.lang.Exception
- Propagate JMX invocation error
-
addServiced
@Deprecated protected void addServiced(java.lang.String name) throws java.lang.Exception
Deprecated.Unused. Will be removed in Tomcat 10.1.x onwards. UsetryAddServiced(java.lang.String)
Invoke the addServiced method on the deployer.- Parameters:
name
- The webapp name- Throws:
java.lang.Exception
- Propagate JMX invocation error
-
tryAddServiced
protected boolean tryAddServiced(java.lang.String name) throws java.lang.Exception
Attempt to mark a context as being serviced- Parameters:
name
- The context name- Returns:
true
if the application was marked as being serviced andfalse
if the application was already marked as being serviced- Throws:
java.lang.Exception
- Error invoking the deployer
-
removeServiced
protected void removeServiced(java.lang.String name) throws java.lang.Exception
Invoke the removeServiced method on the deployer.- Parameters:
name
- The webapp name- Throws:
java.lang.Exception
- Propagate JMX invocation error
-
uploadWar
protected void uploadWar(java.io.PrintWriter writer, HttpServletRequest request, java.io.File war, StringManager smClient) throws java.io.IOException
Upload the WAR file included in this request, and store it at the specified file location.- Parameters:
writer
- Writer to render torequest
- The servlet request we are processingwar
- The file into which we should store the uploaded WARsmClient
- The StringManager used to construct i18n messages based on the Locale of the client- Throws:
java.io.IOException
- if an I/O error occurs during processing
-
validateContextName
protected static boolean validateContextName(ContextName cn, java.io.PrintWriter writer, StringManager smClient)
-
getConnectorCiphers
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getConnectorCiphers(StringManager smClient)
-
getConnectorCerts
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getConnectorCerts(StringManager smClient)
-
getConnectorTrustedCerts
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getConnectorTrustedCerts(StringManager smClient)
-
-