Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tomcat Wiki" for change 
notification.

The "HowTo" page has been changed by ChuckCaldarale:
http://wiki.apache.org/tomcat/HowTo?action=diff&rev1=133&rev2=134

  The best way is to use jsvc, available as part of the 
[[http://commons.apache.org/daemon/jsvc.html|commons-daemon]] project.
  
  ----
+ One way is to put Apache httpd with mod_jk before your Tomcat servers, and 
use ports >=1024 in the Tomcat(s). However, if httpd is not needed for some 
other reason, this is the most inefficient approach.
- Is there a way to allow normal user(non-root) to start/stop the tomcat 
server. Tried assigning permission, did not work. Read thru some articles, 
stated that only root has permission to port below 1025. How can i allow a 
non-root user to do so ? thks in adv. :)
- 
- - malathi ranjit singh
  
  ----
- One way is to put Apache httpd with mod_jk before your Tomcat servers, and 
use ports >=1024 in the Tomcat(s). Since we do it that way, it's the only way I 
know.
- 
- BTW, you should read the 1st howto. ;)
- 
  Another method is to use SetUID scripts (assuming you have the capability) to 
do this.  Here's how I do it.
  
  Create a file called foo.c with this content (replace "/path/startupscript" 
with the tomcat startup script):
@@ -215, +209 @@

  === Tomcat 6.0 and later ===
  Development of Administration web app was ceased and it is no longer provided 
for Tomcat 6.0 and later versions.
  
- An alternative is to use 3-rd party applications, such as PSI Probe. See 
[[AddOns]] page for links.
+ An alternative is to use 3-rd party applications, such as PSI Probe. See 
AddOns page for links.
  
  == How do I add JARs or classes to the common classloader without adding them 
to $CATALINA_HOME/lib? ==
  Either
@@ -230, +224 @@

  == Where and how do I set memory related settings to improve Tomcat 
performance? ==
  When your web application is using large memory as this memory size default 
setting can be too small. One way to address this problem is to set a larger 
heap size.
  
- If you start Tomcat by using the standard '''script files''' (such as 
`CATALINA_HOME/bin/catalina.bat` or `catalina.sh`), this can be done by setting 
`CATALINA_OPTS` environment variable. The recommended way to do so is to create 
a `setenv.bat` or `setenv.sh` file, — read 
[[http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt|RUNNING.txt]] for details.
+ If you start Tomcat by using the standard '''script files''' (such as 
`CATALINA_HOME/bin/catalina.bat` or `catalina.sh`), this can be done by setting 
`CATALINA_OPTS` environment variable. The recommended way to do so is to create 
a `setenv.bat` or `setenv.sh` file, — read 
[[http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt|RUNNING.txt]] for details.
  
  Let say you want to increase it to 256 MB (as you required but make sure you 
have enough amount of physical memory/RAM and for 32bit system, use no more 
than 1.0-1.1 GB heap space size ). Set the `CATALINA_OPTS` to the value of 
{{{-Xms256m -Xmx256m}}}. In some cases it is better to set slightly lower size 
for `-Xms`.
  
+ For `setenv.bat` use the following line:  {{{ set CATALINA_OPTS=-Xms256m 
-Xmx256m }}} <<BR>> For `setenv.sh` use the following:  {{{ 
CATALINA_OPTS='-Xms256m -Xmx256m' }}}
- For `setenv.bat` use the following line:  {{{ set CATALINA_OPTS=-Xms256m 
-Xmx256m }}} <<BR>>
- For `setenv.sh` use the following:  {{{ CATALINA_OPTS='-Xms256m -Xmx256m' }}}
  
  There are other parameters that can be added, depending on your application 
and requirements, e.g: {{{'-XX:MaxPermSize'}}}.
  
  For other parameters, look at the following pages:
  
   * [[FAQ/Memory]]
-  * [[OutOfMemory]]
+  * OutOfMemory
  
  If you are running Tomcat as a '''Windows service''', then environment 
variables and `setenv.bat` script have no effect. The relevant settings for the 
service wrapper application are stored in the Windows registry. They can be 
edited via Configuration application (`tomcat<N>w.exe`). See "Java" tab in the 
configuration dialog. The`-Xms` and `-Xmx` options are configured in fields 
named "Initial memory pool" and "Maximum memory pool". Other options can be 
added to "Java Options" field as if they were specified on the command line of 
java executable.
  
@@ -412, +405 @@

  Context context = (Context) host.findChild("myContext");
  Realm realm = context.getRealm();
  }}}
- 
  '''Warning:''' The above recipe on how to obtain a `Context` for a web 
application is a bit obsolete and does not work in Tomcat 7 and later (as 
Server is no longer a singleton). There are other ways to achieve that. An easy 
one is to add a `Valve` or `Listener` to a context, as those classes have 
access to Tomcat internals. There may be other ways mentioned in the archives 
of the [[FAQ/Tomcat_User|users mailing list]].
  
  == How do I redirect System.out and System.err to my web page? ==
@@ -859, +851 @@

  === If you are running on Microsoft Windows ===
  You can try to use SendSignal, developed specifically for this purpose. Make 
sure you read the comments for certain sitautions (e.g. running as a service, 
RDP connections, etc.). 
http://www.latenighthacking.com/projects/2003/sendSignal/
  
- 
  === If you are running Tomcat as a service on Microsoft Windows ===
  Edit your service to add the "//MS//" option to the command line. This 
enabled the "Monitor Service" which puts an icon in the system tray while 
Tomcat is running. Right-clicking the Tomcat monitor in the system tray allows 
you to produce a thread dump in stdout.
  
@@ -869, +860 @@

  This will produce a thread dump on standard output, but may not be possible 
to capture to a file.
  
  == How do I read a Java thread dump ? ==
- 
  Java thread dumps are just text files, so you can read them with any text 
editor. There are some tools that can make your life easier, especially if you 
need to look at more than one thread dump at once.
  
  One such tool is the Thread Dump Viewer (TDV), which you can find here: 
http://tdv.sourceforge.net/. It is a bit old (last release: 2007) but it can be 
somewhat helpful.
  
  == How do I obtain a heap dump? ==
+ See 
[[http://wiki.eclipse.org/index.php/MemoryAnalyzer#Getting_a_Heap_Dump|Getting 
a Heap Dump]] on the help pages of [[http://eclipse.org/mat/|Eclipse Memory 
Analysis Tool]].
- 
- See 
[[http://wiki.eclipse.org/index.php/MemoryAnalyzer#Getting_a_Heap_Dump|Getting 
a Heap Dump]]
- on the help pages of [[http://eclipse.org/mat/|Eclipse Memory Analysis Tool]].
- 
  
  == How do I add my own custom MBean to monitor my application within Tomcat 
5/6? ==
- 
  First of all, you can read [[http://oss.wxnet.org/mbeans.html|this great 
tutorial]] from Christopher Blunck ( ch...@wxnet.org ). I will just add my 
comments and improvements.
  
  1. Start your Tomcat and check that you have access to 
http://localhost:8080/manager/jmxproxy/. It means that JMX is enabled on your 
Tomcat configuration (if not, check if the following line is in your 
/conf/server.xml file :   `<Listener 
className="org.apache.catalina.mbeans.ServerLifecycleListener" />`. Otherwise, 
check the Tomcat documentation to activate it). Let this page opened to check 
further if your custom Mbean is detected by Tomcat.<<BR>>
@@ -984, +970 @@

          return mbserver;
      }
  }}}
- Here is a capture of the println() : 
https://picasaweb.google.com/lh/photo/jzVX9-NBGwF57A0m8qqv2Q?feat=directlink. 
Tomcat seems to register 2nd Mbean server but when I try to fetch mine from its 
!AgentId (here "myMBServer"), nothing is found. In my opinion, Tomcat might 
re-implement the ''MBeanServerFactory'' java class to control the server 
creation. Then, it doesn't keep a reference to the newly created MBean server. 
Moreover, if Tomcat re-implement the MBeanFactory class, there is no method to 
directly add MBean (see the 
[[http://tomcat.apache.org/tomcat-6.0-doc/api/index.html]]).<<BR>>
+ Here is a capture of the println() : 
https://picasaweb.google.com/lh/photo/jzVX9-NBGwF57A0m8qqv2Q?feat=directlink. 
Tomcat seems to register 2nd Mbean server but when I try to fetch mine from its 
!AgentId (here "myMBServer"), nothing is found. In my opinion, Tomcat might 
re-implement the ''MBeanServerFactory'' java class to control the server 
creation. Then, it doesn't keep a reference to the newly created MBean server. 
Moreover, if Tomcat re-implement the MBeanFactory class, there is no method to 
directly add MBean (see the 
http://tomcat.apache.org/tomcat-6.0-doc/api/index.html).<<BR>>
  
  In my application architecture, I placed the 2 MBeans files (the interface 
and its implementation) in a particular package (I don't think its compulsary 
but definitely more aesthetic). Compile those one in a jar archive and place it 
in the Tomcat's library folder (/lib).<<BR>>
  
@@ -1047, +1033 @@

  MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  //call operations with invoke(...) and attributes with getAttributes(...)
  }}}
- 
  Do not hesitate to check the !ManagementFactory class javadoc.
  
  ----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to