RE: Re: starting and stopping Tomcat from Java code

2005-12-15 Thread andy gordon
Oleg, 
   
  Have you looked into managing the tomcat instance with MBeans. All you need 
to do is establish a connection to the other JVM with an MBeanServerConnection 
instance. This does require a port to be exposed from Tomcat for remote 
monitoring. But once you have the connection you can do what you want with the 
remote Tomcat. Just look at how JConsole monitors/manages remote JVM 
applications for an example.
   
  HTH 
   
  - andy

Oleg Lebedev [EMAIL PROTECTED] wrote:
  Yes, that would work if I had a handle to the embedded instance. The thing is 
that embedded tomcat is running in a separate VM and I need to be able to shut 
it down. I don't really need to use Embedded class if only I could get 
Bootstrap or Catalina classes to work without having to have the whole tomcat 
directory on disk.


-Original Message-
From: news on behalf of Bill Barker
Sent: Wed 12/14/2005 8:14 PM
To: users@tomcat.apache.org
Subject: Re: starting and stopping Tomcat from Java code

Urm, something like:
tomcat.stop();

where 'tomcat' is your Embedded instance?

Oleg Lebedev wrote in message 
news:[EMAIL PROTECTED]
Hello,

I am trying to configure, start and then shutdown Tomcat from my Java
class. I am planning to have all the jars required by Tomcat on the
classpath and I would like to be able to specify the port number and
host using method calls. I would prefer not to ship Tomcat configuration
files, such as server.xml with my application and be able to configure
Tomcat from code before starting it.

I tried using Boostrap class, but it requires catalina.home and
catalina.base, which I would like to avoid using.
I tried using Embed class and it worked, but I still had to set
catalina.home so that it can find tomcat-users.xml. But, this is
acceptable.

I have not been able to shut Tomcat down from my Java code. Note that I
won't have a handle to the Catalina instance started, because Tomcat
needs to be started before my application starts in a separate VM, and
then killed when my application exists.

I would appreciate any feedback on how to do this or what Tomcat classes
I should take a look at.

Thanks.

Oleg





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


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
If you have questions about this email, please
contact the IT Help Desk.

Mail



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

  



-
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 

RE: Re: starting and stopping Tomcat from Java code

2005-12-15 Thread Oleg Lebedev
Andy, thanks for the hint. It seems like the right solution for our
problem.

We had to get this working by today, so we ended up extending Embedded
class and provided shutdown hooks just like Catalina class does, but
without requiring server.xml configuration. Using the new class we can
start a tomcat instance and shutdown a remote tomcat instance by sending
a shutdown command to a certain host and port.
Thanks everybody for your help.

Regards.

Oleg

-Original Message-
From: andy gordon [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 15, 2005 5:16 AM
To: Tomcat Users List
Subject: RE: Re: starting and stopping Tomcat from Java code

Oleg, 
   
  Have you looked into managing the tomcat instance with MBeans. All you
need to do is establish a connection to the other JVM with an
MBeanServerConnection instance. This does require a port to be exposed
from Tomcat for remote monitoring. But once you have the connection you
can do what you want with the remote Tomcat. Just look at how JConsole
monitors/manages remote JVM applications for an example.
   
  HTH 
   
  - andy

Oleg Lebedev [EMAIL PROTECTED] wrote:
  Yes, that would work if I had a handle to the embedded instance. The
thing is that embedded tomcat is running in a separate VM and I need to
be able to shut it down. I don't really need to use Embedded class if
only I could get Bootstrap or Catalina classes to work without having to
have the whole tomcat directory on disk.


-Original Message-
From: news on behalf of Bill Barker
Sent: Wed 12/14/2005 8:14 PM
To: users@tomcat.apache.org
Subject: Re: starting and stopping Tomcat from Java code

Urm, something like:
tomcat.stop();

where 'tomcat' is your Embedded instance?

Oleg Lebedev wrote in message
news:[EMAIL PROTECTED]
Hello,

I am trying to configure, start and then shutdown Tomcat from my Java
class. I am planning to have all the jars required by Tomcat on the
classpath and I would like to be able to specify the port number and
host using method calls. I would prefer not to ship Tomcat configuration
files, such as server.xml with my application and be able to configure
Tomcat from code before starting it.

I tried using Boostrap class, but it requires catalina.home and
catalina.base, which I would like to avoid using.
I tried using Embed class and it worked, but I still had to set
catalina.home so that it can find tomcat-users.xml. But, this is
acceptable.

I have not been able to shut Tomcat down from my Java code. Note that I
won't have a handle to the Catalina instance started, because Tomcat
needs to be started before my application starts in a separate VM, and
then killed when my application exists.

I would appreciate any feedback on how to do this or what Tomcat classes
I should take a look at.

Thanks.

Oleg





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


--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail



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

  



-
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping
--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail


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



Re: starting and stopping Tomcat from Java code

2005-12-14 Thread Stas Ostapenko
Maybe this can help (Embed with Tomcat) ?
http://www.vsj.co.uk/articles/display.asp?id=319

On 12/15/05, Oleg Lebedev [EMAIL PROTECTED] wrote:
 Hello,

 I am trying to configure, start and then shutdown Tomcat from my Java
 class. I am planning to have all the jars required by Tomcat on the
 classpath and I would like to be able to specify the port number and
 host using method calls. I would prefer not to ship Tomcat configuration
 files, such as server.xml with my application and be able to configure
 Tomcat from code before starting it.

 I tried using Boostrap class, but it requires catalina.home and
 catalina.base, which I would like to avoid using.
 I tried using Embed class and it worked, but I still had to set
 catalina.home so that it can find tomcat-users.xml. But, this is
 acceptable.

 I have not been able to shut Tomcat down from my Java code. Note that I
 won't have a handle to the Catalina instance started, because Tomcat
 needs to be started before my application starts in a separate VM, and
 then killed when my application exists.

 I would appreciate any feedback on how to do this or what Tomcat classes
 I should take a look at.

 Thanks.

 Oleg




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



Re: starting and stopping Tomcat from Java code

2005-12-14 Thread Wendy Smoak
On 12/14/05, Oleg Lebedev [EMAIL PROTECTED] wrote:

 I am trying to configure, start and then shutdown Tomcat from my Java
 class.

No idea if it will do what you want, but that requirement made me
think of Cargo:
   http://cargo.codehaus.org/

--
Wendy

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



RE: starting and stopping Tomcat from Java code

2005-12-14 Thread Oleg Lebedev
Stas,

This looks like a great article, and will help me to get embedded Tomcat
working. But how do I stop a running Tomcat instance from java?

Thanks.

Oleg

-Original Message-
From: Stas Ostapenko [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 14, 2005 4:28 PM
To: Tomcat Users List
Subject: Re: starting and stopping Tomcat from Java code

Maybe this can help (Embed with Tomcat) ?
http://www.vsj.co.uk/articles/display.asp?id=319

On 12/15/05, Oleg Lebedev [EMAIL PROTECTED] wrote:
 Hello,

 I am trying to configure, start and then shutdown Tomcat from my Java 
 class. I am planning to have all the jars required by Tomcat on the 
 classpath and I would like to be able to specify the port number and 
 host using method calls. I would prefer not to ship Tomcat 
 configuration files, such as server.xml with my application and be 
 able to configure Tomcat from code before starting it.

 I tried using Boostrap class, but it requires catalina.home and 
 catalina.base, which I would like to avoid using.
 I tried using Embed class and it worked, but I still had to set 
 catalina.home so that it can find tomcat-users.xml. But, this is 
 acceptable.

 I have not been able to shut Tomcat down from my Java code. Note that 
 I won't have a handle to the Catalina instance started, because Tomcat

 needs to be started before my application starts in a separate VM, and

 then killed when my application exists.

 I would appreciate any feedback on how to do this or what Tomcat 
 classes I should take a look at.

 Thanks.

 Oleg




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


--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail


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



RE: starting and stopping Tomcat from Java code

2005-12-14 Thread Oleg Lebedev
Thanks, Wendy.

I looked at cargo and it seems that it requires the container to be
installed on the local machine in order to be able to start or stop it.

In my case I have Tomcat running on some machine with a known IP address
and port number. I need to be able to send a shutdown command to that
Tomcat instance and have it stutdown itself.

I just noticed this piece of code in Catalina.stopServer(String[]):

Socket socket = new Socket(127.0.0.1,
server.getPort());
OutputStream stream = socket.getOutputStream();
String shutdown = server.getShutdown();
for (int i = 0; i  shutdown.length(); i++)
stream.write(shutdown.charAt(i));
stream.flush();
stream.close();
socket.close();

This may be what I need to use in my Java class to shut down the local
Tomcat instance.

Any ideas on whether this is the right way to shut down a stand-alone
Tomcat instance?

Thanks.

Oleg

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 14, 2005 4:44 PM
To: Tomcat Users List
Subject: Re: starting and stopping Tomcat from Java code

On 12/14/05, Oleg Lebedev [EMAIL PROTECTED] wrote:

 I am trying to configure, start and then shutdown Tomcat from my Java 
 class.

No idea if it will do what you want, but that requirement made me think
of Cargo:
   http://cargo.codehaus.org/

--
Wendy

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


--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail


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



RE: starting and stopping Tomcat from Java code

2005-12-14 Thread Iannis Hanen
Hi Oleg,

The piece of code you just mentioned is what lies behind the server
tag in the server.xml file. You can set the server tag this way:

Server port=1234 shutdown=myShutdown

If you connect to port 1234 on the tomcat machine and type in the
myShutdown password, tomcat will shutdown. However, I am pretty sure
that this port is opened only for callers from localhost. So, if you
intend to stop it remotely, this may not be possible. You may have to
use a proxy of some kind to relay your call so that tomcat believes the
call comes from localhost.

Iannis

-Original Message-
From: Oleg Lebedev [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 14, 2005 4:27 PM
To: Tomcat Users List
Subject: RE: starting and stopping Tomcat from Java code

Thanks, Wendy.

I looked at cargo and it seems that it requires the container to be
installed on the local machine in order to be able to start or stop it.

In my case I have Tomcat running on some machine with a known IP address
and port number. I need to be able to send a shutdown command to that
Tomcat instance and have it stutdown itself.

I just noticed this piece of code in Catalina.stopServer(String[]):

Socket socket = new Socket(127.0.0.1,
server.getPort());
OutputStream stream = socket.getOutputStream();
String shutdown = server.getShutdown();
for (int i = 0; i  shutdown.length(); i++)
stream.write(shutdown.charAt(i));
stream.flush();
stream.close();
socket.close();

This may be what I need to use in my Java class to shut down the local
Tomcat instance.

Any ideas on whether this is the right way to shut down a stand-alone
Tomcat instance?

Thanks.

Oleg

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 14, 2005 4:44 PM
To: Tomcat Users List
Subject: Re: starting and stopping Tomcat from Java code

On 12/14/05, Oleg Lebedev [EMAIL PROTECTED] wrote:

 I am trying to configure, start and then shutdown Tomcat from my Java 
 class.

No idea if it will do what you want, but that requirement made me think
of Cargo:
   http://cargo.codehaus.org/

--
Wendy

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


--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail


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


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



RE: starting and stopping Tomcat from Java code

2005-12-14 Thread Oleg Lebedev

Great, sending that shutdown command to a Tomcat server started with
server.xml file on the disk worked.

But how can I specify what the server shutdown command is when I start
the server in embedded mode on a certain port? (See code below)


private static void startTomcat(){
String hostName = localhost;
int port = ;

String commonPath = C:/myapp;
String catalinaHome = commonPath + /tomcat;
System.setProperty(catalina.home, catalinaHome);

Embedded embedded = new Embedded();

MemoryRealm memRealm = new MemoryRealm();
embedded.setRealm(memRealm);

Engine engine = embedded.createEngine();

Host host = embedded.createHost(hostName, );
engine.addChild(host);
Context rootCtx = embedded.createContext(, /);
rootCtx.setPrivileged(true);
host.addChild(rootCtx);
embedded.addEngine(engine);

Connector httpConnector = embedded.createConnector(
(java.net.InetAddress) null, port,
false);

embedded.addConnector(httpConnector);
embedded.start();
} 


-Original Message-
From: Iannis Hanen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 14, 2005 5:35 PM
To: Tomcat Users List
Cc: Iannis Hanen
Subject: RE: starting and stopping Tomcat from Java code

Hi Oleg,

The piece of code you just mentioned is what lies behind the server
tag in the server.xml file. You can set the server tag this way:

Server port=1234 shutdown=myShutdown

If you connect to port 1234 on the tomcat machine and type in the
myShutdown password, tomcat will shutdown. However, I am pretty sure
that this port is opened only for callers from localhost. So, if you
intend to stop it remotely, this may not be possible. You may have to
use a proxy of some kind to relay your call so that tomcat believes the
call comes from localhost.

Iannis

-Original Message-
From: Oleg Lebedev [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 14, 2005 4:27 PM
To: Tomcat Users List
Subject: RE: starting and stopping Tomcat from Java code

Thanks, Wendy.

I looked at cargo and it seems that it requires the container to be
installed on the local machine in order to be able to start or stop it.

In my case I have Tomcat running on some machine with a known IP address
and port number. I need to be able to send a shutdown command to that
Tomcat instance and have it stutdown itself.

I just noticed this piece of code in Catalina.stopServer(String[]):

Socket socket = new Socket(127.0.0.1,
server.getPort());
OutputStream stream = socket.getOutputStream();
String shutdown = server.getShutdown();
for (int i = 0; i  shutdown.length(); i++)
stream.write(shutdown.charAt(i));
stream.flush();
stream.close();
socket.close();

This may be what I need to use in my Java class to shut down the local
Tomcat instance.

Any ideas on whether this is the right way to shut down a stand-alone
Tomcat instance?

Thanks.

Oleg

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 14, 2005 4:44 PM
To: Tomcat Users List
Subject: Re: starting and stopping Tomcat from Java code

On 12/14/05, Oleg Lebedev [EMAIL PROTECTED] wrote:

 I am trying to configure, start and then shutdown Tomcat from my Java 
 class.

No idea if it will do what you want, but that requirement made me think
of Cargo:
   http://cargo.codehaus.org/

--
Wendy

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


--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail


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


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


--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail


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



RE: starting and stopping Tomcat from Java code

2005-12-14 Thread andy gordon
There is an MBean for the Server and I believe that you can specify the command 
there.

Oleg Lebedev [EMAIL PROTECTED] wrote:  
Great, sending that shutdown command to a Tomcat server started with
server.xml file on the disk worked.

But how can I specify what the server shutdown command is when I start
the server in embedded mode on a certain port? (See code below)


private static void startTomcat(){
String hostName = localhost;
int port = ;

String commonPath = C:/myapp;
String catalinaHome = commonPath + /tomcat;
System.setProperty(catalina.home, catalinaHome);

Embedded embedded = new Embedded();

MemoryRealm memRealm = new MemoryRealm();
embedded.setRealm(memRealm);

Engine engine = embedded.createEngine();

Host host = embedded.createHost(hostName, );
engine.addChild(host);
Context rootCtx = embedded.createContext(, /);
rootCtx.setPrivileged(true);
host.addChild(rootCtx);
embedded.addEngine(engine);

Connector httpConnector = embedded.createConnector(
(java.net.InetAddress) null, port,
false);

embedded.addConnector(httpConnector);
embedded.start();
} 


-Original Message-
From: Iannis Hanen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 14, 2005 5:35 PM
To: Tomcat Users List
Cc: Iannis Hanen
Subject: RE: starting and stopping Tomcat from Java code

Hi Oleg,

The piece of code you just mentioned is what lies behind the 
tag in the server.xml file. You can set the tag this way:



If you connect to port 1234 on the tomcat machine and type in the
myShutdown password, tomcat will shutdown. However, I am pretty sure
that this port is opened only for callers from localhost. So, if you
intend to stop it remotely, this may not be possible. You may have to
use a proxy of some kind to relay your call so that tomcat believes the
call comes from localhost.

Iannis

-Original Message-
From: Oleg Lebedev [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 14, 2005 4:27 PM
To: Tomcat Users List
Subject: RE: starting and stopping Tomcat from Java code

Thanks, Wendy.

I looked at cargo and it seems that it requires the container to be
installed on the local machine in order to be able to start or stop it.

In my case I have Tomcat running on some machine with a known IP address
and port number. I need to be able to send a shutdown command to that
Tomcat instance and have it stutdown itself.

I just noticed this piece of code in Catalina.stopServer(String[]):

Socket socket = new Socket(127.0.0.1,
server.getPort());
OutputStream stream = socket.getOutputStream();
String shutdown = server.getShutdown();
for (int i = 0; i  shutdown.length(); i++)
stream.write(shutdown.charAt(i));
stream.flush();
stream.close();
socket.close();

This may be what I need to use in my Java class to shut down the local
Tomcat instance.

Any ideas on whether this is the right way to shut down a stand-alone
Tomcat instance?

Thanks.

Oleg

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 14, 2005 4:44 PM
To: Tomcat Users List
Subject: Re: starting and stopping Tomcat from Java code

On 12/14/05, Oleg Lebedev wrote:

 I am trying to configure, start and then shutdown Tomcat from my Java 
 class.

No idea if it will do what you want, but that requirement made me think
of Cargo:
http://cargo.codehaus.org/

--
Wendy

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


--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail


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


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


--
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.
If you have questions about this email, please contact the IT Help Desk.

Mail


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





-
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 

Re: starting and stopping Tomcat from Java code

2005-12-14 Thread Bill Barker
Urm, something like:
   tomcat.stop();

where 'tomcat' is your Embedded instance?

Oleg Lebedev [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Hello,

I am trying to configure, start and then shutdown Tomcat from my Java
class. I am planning to have all the jars required by Tomcat on the
classpath and I would like to be able to specify the port number and
host using method calls. I would prefer not to ship Tomcat configuration
files, such as server.xml with my application and be able to configure
Tomcat from code before starting it.

I tried using Boostrap class, but it requires catalina.home and
catalina.base, which I would like to avoid using.
I tried using Embed class and it worked, but I still had to set
catalina.home so that it can find tomcat-users.xml. But, this is
acceptable.

I have not been able to shut Tomcat down from my Java code. Note that I
won't have a handle to the Catalina instance started, because Tomcat
needs to be started before my application starts in a separate VM, and
then killed when my application exists.

I would appreciate any feedback on how to do this or what Tomcat classes
I should take a look at.

Thanks.

Oleg





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



Re: starting and stopping Tomcat from Java code

2005-12-14 Thread Wade Chandler
--- Bill Barker [EMAIL PROTECTED] wrote:

 Urm, something like:
tomcat.stop();
 
 where 'tomcat' is your Embedded instance?
 
 Oleg Lebedev [EMAIL PROTECTED] wrote in
 message 

news:[EMAIL PROTECTED]
 Hello,
 
 I am trying to configure, start and then shutdown
 Tomcat from my Java
 class. I am planning to have all the jars required
 by Tomcat on the
 classpath and I would like to be able to specify the
 port number and
 host using method calls. I would prefer not to ship
 Tomcat configuration
 files, such as server.xml with my application and be
 able to configure
 Tomcat from code before starting it.
 
 I tried using Boostrap class, but it requires
 catalina.home and
 catalina.base, which I would like to avoid using.
 I tried using Embed class and it worked, but I still
 had to set
 catalina.home so that it can find tomcat-users.xml.
 But, this is
 acceptable.
 
 I have not been able to shut Tomcat down from my
 Java code. Note that I
 won't have a handle to the Catalina instance
 started, because Tomcat
 needs to be started before my application starts in
 a separate VM, and
 then killed when my application exists.
 
 I would appreciate any feedback on how to do this or
 what Tomcat classes
 I should take a look at.
 
 Thanks.
 
 Oleg
 
 
 
 
 

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

I guess if you know how to do this when you do have an
instance in the same VM then you can simply use the
web application you are using in the backend.  I
assume you are connecting to this server from clients
or something.  In the code creating the instance store
the Object in a static variable in a package you
install in the extensions directory of the executing
vm or the trusted libraries for the tomcat instance. 
This way they are available to all classes in the
Tomcat instance.  Then you can shut it down from your
other application by accessing a servlet or soemthing.
 You might have to play around with the security
access for the methods though...not sure.  Anyways,
basically you just make a simple class so you can
install it like that.  It won't be something you
change much and it's sole purpose is so it's part of
your class package and system.  It could be as simple
as a single class with nothing but a static instance
of the Tomcat server so you can access it.

Just a simple idea, but should work unless you can
simply edit the security file to allow your web app
code to access the internal tomcat engine it's running
in.  Which you should be able to do that as well.

Wade

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



RE: Re: starting and stopping Tomcat from Java code

2005-12-14 Thread Oleg Lebedev
Yes, that would work if I had a handle to the embedded instance. The thing is 
that embedded tomcat is running in a separate VM and I need to be able to shut 
it down. I don't really need to use Embedded class if only I could get 
Bootstrap or Catalina classes to work without having to have the whole tomcat 
directory on disk.


-Original Message-
From: news on behalf of Bill Barker
Sent: Wed 12/14/2005 8:14 PM
To: users@tomcat.apache.org
Subject:  Re: starting and stopping Tomcat from Java code
 
Urm, something like:
   tomcat.stop();

where 'tomcat' is your Embedded instance?

Oleg Lebedev [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Hello,

I am trying to configure, start and then shutdown Tomcat from my Java
class. I am planning to have all the jars required by Tomcat on the
classpath and I would like to be able to specify the port number and
host using method calls. I would prefer not to ship Tomcat configuration
files, such as server.xml with my application and be able to configure
Tomcat from code before starting it.

I tried using Boostrap class, but it requires catalina.home and
catalina.base, which I would like to avoid using.
I tried using Embed class and it worked, but I still had to set
catalina.home so that it can find tomcat-users.xml. But, this is
acceptable.

I have not been able to shut Tomcat down from my Java code. Note that I
won't have a handle to the Catalina instance started, because Tomcat
needs to be started before my application starts in a separate VM, and
then killed when my application exists.

I would appreciate any feedback on how to do this or what Tomcat classes
I should take a look at.

Thanks.

Oleg





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


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
If you have questions about this email, please
contact the IT Help Desk.

Mail



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