You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by антон кузнецов <an...@mail.ru> on 2009/02/12 10:32:15 UTC

Running tomcat from my code

 
Hello. How can i start and stop tomcat from my own code? Something like startTomcat() and stopTomcat() methods, which in its turn calls to some of tomcat methods. (There is a problem that doesn't allow me to simply calls *.bat(*.sh) files). tomcat version = 6.0.13. Thanks for your work.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by Gregor Schneider <rc...@googlemail.com>.
The main question is:

- Of which type is the OP's application-code? Java? C? C++? Lisp? ;)

But most important.

What is the OP trying to achieve? It might well be that there's a
smarter solution to the original request.

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by André Warnier <aw...@ice-sa.com>.
Mikolaj Rydzewski wrote:
[...]

> You can embed Tomcat in your code as well.
> 
I'm not so good at Tomcat, and even less at Java.  So this is pure 
curiosity on my part, but maybe it could also interest the OP.

Can you elaborate a bit on the above, in just 2 lines ?
Don't go too deep in Java, or I would be lost.
Is it like :
You start a JVM with your own code, then your code starts a thread 
running Tomcat's bootstrap.jar, and Tomcat then starts its own threads 
etc..  Because your application started the main Tomcat thread, it has 
control over it ?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by André Warnier <aw...@ice-sa.com>.
Mikolaj Rydzewski wrote:
> André Warnier wrote:
>> Anyway, to get back to the OP's question thus, that was not really a 
>> simple answer to his problem, was it ?
> He didn't say he needs simple answer.
> 
Not in so many words, Pan Mikolaj, but the general tone of the question 
kind of implied that.
Which is why I felt qualified enough to give a first tentative answer.
Usually, I do not dare, because they are way over my head.
Fortunately, there are real experts here to correct my mistakes.
;-)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
André Warnier wrote:
> Anyway, to get back to the OP's question thus, that was not really a 
> simple answer to his problem, was it ?
He didn't say he needs simple answer.

-- 
Mikolaj Rydzewski <mi...@ceti.pl>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by André Warnier <aw...@ice-sa.com>.
Mikolaj Rydzewski wrote:
> André Warnier wrote:
>> I'm not so good at Tomcat, and even less at Java.  So this is pure 
>> curiosity on my part, but maybe it could also interest the OP.
>>
>> Can you elaborate a bit on the above, in just 2 lines ?
>> Don't go too deep in Java, or I would be lost.
> Use google ;-)
> 
> http://www.onjava.com/pub/a/onjava/2002/04/03/tomcat.html
> http://www.google.pl/search?q=how+to+embed+tomcat
> 
> 
I did not think I would find a 2-line answer in Google.
And apparently I was right.  Thanks anyway for suggesting it.
Ok, so it's apparently a lot more complicated than what I suggested.

Why did I expect a 2-line answer with anything to do with Java anyway, 
silly me.
;-)
(yes, I know, it depends how long the lines are..)

Anyway, to get back to the OP's question thus, that was not really a 
simple answer to his problem, was it ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
André Warnier wrote:
> I'm not so good at Tomcat, and even less at Java.  So this is pure 
> curiosity on my part, but maybe it could also interest the OP.
>
> Can you elaborate a bit on the above, in just 2 lines ?
> Don't go too deep in Java, or I would be lost.
Use google ;-)

http://www.onjava.com/pub/a/onjava/2002/04/03/tomcat.html
http://www.google.pl/search?q=how+to+embed+tomcat


-- 
Mikolaj Rydzewski <mi...@ceti.pl>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Running tomcat from my code

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com]
> Subject: Re: Running tomcat from my code
>
> > You can embed Tomcat in your code as well.
>
> Can you elaborate a bit on the above, in just 2 lines ?
> Don't go too deep in Java, or I would be lost.

You have to be lost before you can be found:
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/startup/Embedded.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by André Warnier <aw...@ice-sa.com>.
Mikolaj Rydzewski wrote:
[...]

> You can embed Tomcat in your code as well.
> 
I'm not so good at Tomcat, and even less at Java.  So this is pure 
curiosity on my part, but maybe it could also interest the OP.

Can you elaborate a bit on the above, in just 2 lines ?
Don't go too deep in Java, or I would be lost.
Is it like :
You start a JVM with your own code, then your code starts a thread 
running Tomcat's bootstrap.jar, and Tomcat then starts its own threads 
etc..  Because your application started the main Tomcat thread, it has 
control over it ?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
André Warnier wrote:
> You can probably stop and start individual *applications* within 
> Tomcat programmatically, since that is what the Manager application does.
> Since that application's source code is available, you can peek in it 
> to see how it works.
Use JMX for such purpose.
> But to start Tomcat, I believe the only way is to start the JVM in 
> which Tomcat runs, and for that you probably do need to issue an 
> operating-system level command.
You can embed Tomcat in your code as well.

It depends what your requirements are.

-- 
Mikolaj Rydzewski <mi...@ceti.pl>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by André Warnier <aw...@ice-sa.com>.
антон кузнецов wrote:
>  
> Hello. How can i start and stop tomcat from my own code? Something like startTomcat() and stopTomcat() methods, which in its turn calls to some of tomcat methods. (There is a problem that doesn't allow me to simply calls *.bat(*.sh) files). tomcat version = 6.0.13. Thanks for your work.
> 
I'll try this one.

You can stop the whole Tomcat, by connecting to the "shutdown port" (see 
server.xml) and sending the magic shutdown string defined there.

You can probably stop and start individual *applications* within Tomcat 
programmatically, since that is what the Manager application does.
Since that application's source code is available, you can peek in it to 
see how it works.

But to start Tomcat, I believe the only way is to start the JVM in which 
Tomcat runs, and for that you probably do need to issue an 
operating-system level command.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running tomcat from my code

Posted by André Warnier <aw...@ice-sa.com>.
антон кузнецов wrote:
>  
> Hello. How can i start and stop tomcat from my own code? Something like startTomcat() and stopTomcat() methods, which in its turn calls to some of tomcat methods. (There is a problem that doesn't allow me to simply calls *.bat(*.sh) files). tomcat version = 6.0.13. Thanks for your work.
> 
I'll try this one.

You can stop the whole Tomcat, by connecting to the "shutdown port" (see 
server.xml) and sending the magic shutdown string defined there.

You can probably stop and start individual *applications* within Tomcat 
programmatically, since that is what the Manager application does.
Since that application's source code is available, you can peek in it to 
see how it works.

But to start Tomcat, I believe the only way is to start the JVM in which 
Tomcat runs, and for that you probably do need to issue an 
operating-system level command.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org