This content has been marked as final.
Show 3 replies
-
1. Re: Stop JSF application in tomcat using Java code?
iabughosh Dec 19, 2012 3:41 AM (in response to eswaramoorthy1985) -
2. Re: Stop JSF application in tomcat using Java code?
eswaramoorthy1985 Dec 19, 2012 5:41 AM (in response to iabughosh)Thanks for your support. But its not working
My tomcat-users.xml file
<tomcat-users> <role rolename="manager"/> <user username="tomcat" password="s3cret" roles="manager" /> </tomcat-users>
My code is :
import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.*; import org.apache.commons.httpclient.params.HttpMethodParams; import java.io.*; public class HttpClientTutorial { private static String url = "http://localhost:8080/manager/html/stop?path=/jsfproject"; public static void main(String[] args) { // Create an instance of HttpClient. HttpClient client = new HttpClient(); // Create a method instance. GetMethod method = new GetMethod(url); // Provide custom retry handler is necessary method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); try { // Execute the method. int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { System.err.println("Method failed: " + method.getStatusLine()); } // Read the response body. byte[] responseBody = method.getResponseBody(); // Deal with the response. // Use caution: ensure correct character encoding and is not binary data System.out.println(new String(responseBody)); } catch (HttpException e) { System.err.println("Fatal protocol violation: " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { System.err.println("Fatal transport error: " + e.getMessage()); e.printStackTrace(); } finally { // Release the connection. method.releaseConnection(); } } }
But not stopped application. I got the follwing message in my console
log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
log4j:WARN Please initialize the log4j system properly.
Method failed: HTTP/1.1 401 Unauthorized<html> <head> <title>401 Unauthorized</title> <style> <!-- BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;} H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} PRE, TT {border: 1px dotted #525D76} A {color : black;}A.name {color : black;} --> </style> </head> <body> <h1>401 Unauthorized</h1> <p> You are not authorized to view this page. If you have not changed any configuration files, please examine the file <tt>conf/tomcat-users.xml</tt> in your installation. That file will contain the credentials to let you use this webapp. </p> <p> You will need to add <tt>manager</tt> role to the config file listed above. For example: <pre> <role rolename="manager"/> <user username="tomcat" password="s3cret" roles="manager"/> </pre> </p> <p> For more information - please see the <a href="/docs/manager-howto.html">Manager App HOW-TO</a>. </p> </body> </html>
Help me.
Thanks in advance
-
3. Re: Stop JSF application in tomcat using Java code?
iabughosh Dec 19, 2012 7:07 AM (in response to eswaramoorthy1985)it seems that tomcat container itself doesn't allow external application to perform stop/undeploy operations.