* @return
* @throws DeploymentException
*/
public ProtocolMetaData retrieveContextServletInfo(String context) throws DeploymentException
{
ProtocolMetaData protocolMetaData = new ProtocolMetaData();
HTTPContext httpContext = new HTTPContext(configuration.getBindAddress(), configuration.getBindHttpPort());
JMXConnector jmxc = null;
try
{
jmxc = connect(configuration.getJmxUri());
}
catch (IOException ex)
{
throw new DeploymentException(
"Unable to contruct metadata for archive deployment.\n" +
"Can't connect to '" + configuration.getJmxUri() + "'."
+ "\n Make sure JMX remote acces is enabled Tomcat's JVM - e.g. in startup.sh using $JAVA_OPTS."
+ "\n Example (with no authentication):" + "\n -Dcom.sun.management.jmxremote.port="
+ configuration.getJmxPort() + "\n -Dcom.sun.management.jmxremote.ssl=false"
+ "\n -Dcom.sun.management.jmxremote.authenticate=false", ex);
}
Set<ObjectInstance> servletMBeans;
try
{
servletMBeans = getServletMBeans(jmxc, context);
}
catch (IOException e)
{
throw new DeploymentException("Unable to construct metadata for archive deployment", e);
}
// For each servlet MBean of the given context add the servlet info to the HTTPContext.
for (ObjectInstance oi : servletMBeans)
{
String servletName = oi.getObjectName().getKeyProperty("name");
httpContext.add(new Servlet(servletName, context));
if (log.isLoggable(Level.FINE))
{
log.fine("Added servlet " + oi.toString() + " to HttpContext for archive" + context);
}
}
protocolMetaData.addContext(httpContext);
return protocolMetaData;
}