If that script works, then great.

A less elegant way to do it would be to utilize pgrep. Do a man on it
(not sure what platform you are running on). You can pgrep for the
earliest PID that was run with a number of options. I use it for a Jserv
installation and it works quite nice.

I have not tested it with Tomcat, though.

Good luck,

Ben Ricker
Wellinx, Inc.

On Mon, 2002-09-23 at 15:17, Raj Mettai wrote:
> Hi John,
> 
> I have compiled the code and copied to $CATALINA_HOME$/bin
> then added the following snippet into server.xml
> 
>   <!-- Define the Tomcat Stand-Alone Service -->
>   <Service name="Tomcat-Standalone">
> 
>     <Listener className="PidLifeCycle" />
> 
> 
> when I start the tomcat, I am not seeing any tomcat.pid and I am getting
> the following error in catalina.out
> 
> ERROR reading /opt/tomcat1/conf/server.xml
> At Line 28 /Server/Service/Listener/ className=PidLifeCycle 
> 
> Catalina.start: java.lang.ClassNotFoundException: PidLifeCycle
> java.lang.ClassNotFoundException: PidLifeCycle
>         at
> 
>org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:1127)
>         at
> 
>org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:992)
>         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:120)
>         at
> org.apache.catalina.util.xml.ObjectCreate.start(XmlMapper.java:616)
>         at
> org.apache.catalina.util.xml.XmlMapper.matchStart(XmlMapper.java:412)
>         at
> org.apache.catalina.util.xml.XmlMapper.startElement(XmlMapper.java:91)
>         at
> org.xml.sax.helpers.XMLReaderAdapter.startElement(XMLReaderAdapter.java:329)
>         at
> org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376)
>         at
> 
>org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1284)
>         at
> 
>org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806)
>         at
> 
>org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1182)
>         at
> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
>         at
> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
>         at
> org.xml.sax.helpers.XMLReaderAdapter.parse(XMLReaderAdapter.java:223)
>         at javax.xml.parsers.SAXParser.parse(SAXParser.java:362)
>         at javax.xml.parsers.SAXParser.parse(SAXParser.java:301)
>         at
> org.apache.catalina.util.xml.XmlMapper.readXml(XmlMapper.java:228)
>         at org.apache.catalina.startup.Catalina.start(Catalina.java:725)
>         at
> org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
>         at
> org.apache.catalina.startup.Catalina.process(Catalina.java:179)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)
> 
> 
> thanks 
> 
> -Raj
> 
> 
> >>> [EMAIL PROTECTED] 09/23/02 12:50PM >>>
> 
> Well, in that case, I will include here the content of a message posted
> by
> Tim Funk on 6/13/2002, which has his solution for this, which I find
> pretty
> neat.  Hopefully Tim doesn't mind, and I should add that this would
> break
> portability, most notably on Windows machines.
> 
> On 6/13/2002, Tim Funk wrote:
> 
> For what its worth - I created (and use) a LifecycleListener that runs 
> on startup which logs the process ID into a file called tomcat.pid. 
> Which is created by a shell script called writepid.sh. Below is all the 
> code to get this to work. This code also assumes your current working 
> directory is $CATALINA_HOME.
> 
> --Begin code
> import org.apache.catalina.LifecycleEvent;
> 
> /**
>   * A helper for getting the PID of java so shutting down tomcat is MUCH
>   * easier.
>   */
> public class PidLifeCycle implements
> org.apache.catalina.LifecycleListener {
>       public void lifecycleEvent(LifecycleEvent event)  {
>          if ("start".equals(event.getType())) {
>             try {
>              Runtime.getRuntime().exec("/bin/sh bin/writepid.sh");
>             } catch(Throwable e) {
>                e.printStackTrace();
>             }
>          }
>       }
> }
> --End Code
> 
> The code above will launch the following shell script. Should be in the 
> bin/ directory of your tomcat installation.
> --Begin Shell script
> echo $PPID > logs/tomcat.pid
> --End Shell script
> 
> Then add the following into server.xml
> --Begin server.xml snippet
> <Listener className="PidLifeCycle" />
> --End server.xml snippet
> 
> -Tim
> 
> ====== end =======
> 
> Thanks, Tim!
> 
> John
> 
> 
> > -----Original Message-----
> > From: Anthony Milbourne [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, September 23, 2002 12:45 PM
> > To: 'Tomcat Users List'
> > Subject: RE: Running multiple tomcat instances ?????
> > 
> > 
> > Hi John
> > 
> > I don't think this option is available under Solaris :-(.
> > 
> >         Anthony.
> > 
> > > -----Original Message-----
> > > From:    Turner, John [SMTP:[EMAIL PROTECTED]]
> > > Sent:    23 September 2002 16:17
> > > To:    'Tomcat Users List'
> > > Subject:    RE: Running multiple tomcat instances ?????
> > > 
> > > 
> > > Not sure about Solaris, but on Linux you can add 
> > "--cols=XXX" to the "ps"
> > > command, where "XXX" is a numeric column width.  So, while "ps -ef"
> > > doesn't
> > > show much, "ps -ef --cols=300" will show you everything you 
> > need to know.
> > > 
> > > 
> > > John
> > > 
> > > 
> > > > -----Original Message-----
> > > > From: Raj Mettai [mailto:[EMAIL PROTECTED]]
> > > > Sent: Monday, September 23, 2002 11:14 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Running multiple tomcat instances ?????
> > > > 
> > > > 
> > > > Hi,
> > > > 
> > > > what is the best way to run multiple tomcat instances on 
> > > > single solaris
> > > > box ? 
> > > > 
> > > > 1) Is it Installing multiple tomcats physically.
> > > > 
> > > > or else 
> > > > 
> > > > 2) Installing once and use different server.xml files to 
> > > > start different
> > > > instances.
> > > > 
> > > > any advantages for one over the other ?
> > > > 
> > > > Also, if I do use 2nd process, and if one of the tomcat 
> > crashes, how
> > > > would I know which tomcat is 
> > > > running and which one crashed, because ps -ef|grep tomcat 
> > listing is
> > > > identical for both instances.
> > > > 
> > > > how do you know which instance is using which server.xml ?
> > > > 
> > > > 
> > > > thanks 
> > > > 
> > > > -Raj
> > > > 
> > > 
> > > --
> > > To unsubscribe, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > 
> > 
> > **********************************************************************
> > This email and any files transmitted with it are confidential and
> > intended solely for the use of the individual or entity to whom they
> > are addressed. If you have received this email in error please notify
> > the system manager.
> > This footnote also confirms that this email message has been swept by
> > MIMEsweeper for the presence of computer viruses.
> > www.mimesweeper.com
> > **********************************************************************
> > 
> > 
> > --
> > To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to