Hi!
I'm developing a simple client - server application and what I want is to
automatically reload classes on server side when I change them, I don't
want to restart my server all the time.
How do I do that? Any simple examples? I've look over source code of some
Java application servers (Tomcat, JBoss, ..), but they are too compicated
to understand. :)
Best regards,
Kovi

Signature
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gregor.Kovac@mikropis.si
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
abigale_carson@yahoo.com - 06 Dec 2005 15:34 GMT
Have you checked out the Tomcat Manager application? It's included
with the Tomcat application, and is accessible at
{your-url}:8080/manager/html.
You need to set it up before using it, but it's pretty nice when you
get it going. Here's a reference to how you reload JSP webapps with
it:
http://tomcat.apache.org/tomcat-4.0-doc/manager-howto.html#Reload%20An%20Existin
g%20Application
--or--
http://linkfrog.net/daa6
Hope this helps,
Abigale
Gregor Kovač - 07 Dec 2005 09:43 GMT
> Have you checked out the Tomcat Manager application? It's included
> with the Tomcat application, and is accessible at
[quoted text clipped - 3 lines]
> get it going. Here's a reference to how you reload JSP webapps with
> it:
http://tomcat.apache.org/tomcat-4.0-doc/manager-howto.html#Reload%20An%20Existin
g%20Application
> --or--
>
[quoted text clipped - 3 lines]
>
> Abigale
Hi!
Thanks for your answer, but this is not what I'm looking for. I know how to
set tomcat up to do that, but I want my application to be able to reload my
classes of the fly.
Best regards,
Kovi

Signature
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gregor.Kovac@mikropis.si
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
HalcyonWild - 06 Dec 2005 15:38 GMT
Gregor Kovac wrote:
> Hi!
>
[quoted text clipped - 5 lines]
> Java application servers (Tomcat, JBoss, ..), but they are too compicated
> to understand. :)
Gregor, if you replace the war file , with the recompiled classes, in
the Jboss deployment directory, it will reload the classes. Try it out.
You dont have to restart.
Roedy Green - 06 Dec 2005 19:41 GMT
On Tue, 06 Dec 2005 16:28:21 +0100, Gregor Kovaè
<gregor.kovac@mikropis.si> wrote, quoted or indirectly quoted someone
who said :
>How do I do that? Any simple examples? I've look over source code of some
>Java application servers (Tomcat, JBoss, ..), but they are too compicated
>to understand. :)
You need to create new class loader to load the new version. Then you
have both new and old objects lying around inside the JVM.
See http://mindprod.com/jgloss/classforname.html
http://mindprod.com/jgloss/classloader.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Gregor Kovač - 07 Dec 2005 09:45 GMT
> On Tue, 06 Dec 2005 16:28:21 +0100, Gregor Kova?
> <gregor.kovac@mikropis.si> wrote, quoted or indirectly quoted someone
[quoted text clipped - 9 lines]
> See http://mindprod.com/jgloss/classforname.html
> http://mindprod.com/jgloss/classloader.html
Hi!
Thanks for your answer. This is what I'm looking for.
So.. After, for example, 100 deployments of about 10Mb of classes I'll have
100x10Mb = 1000Mb of memory reserved only for my classes (old and new
versions) ? Is there a way to dispose old versions?
Best regards,
Kovi

Signature
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gregor.Kovac@mikropis.si
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Viator - 07 Dec 2005 10:22 GMT
If I understand you right, what you need is a simple hot deployment
facility. Most servers support this these days and the configuration
depends on server. For tomcat you have to make a context entry in
server.xml file and set reloadable="true". This should work fine. For
other servers chekc out the documentation.
Amit :-)
Roedy Green - 07 Dec 2005 13:01 GMT
On Wed, 07 Dec 2005 10:45:58 +0100, Gregor Kovaè
<gregor.kovac@mikropis.si> wrote, quoted or indirectly quoted someone
who said :
>Thanks for your answer. This is what I'm looking for.
>So.. After, for example, 100 deployments of about 10Mb of classes I'll have
>100x10Mb = 1000Mb of memory reserved only for my classes (old and new
>versions) ? Is there a way to dispose old versions?
If you use a classloader, and discard references to all old objects
and the class loader, the static stuff and the code will be GCed.
Please read the links.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Chris Uppal - 07 Dec 2005 12:11 GMT
Gregor Kovaè wrote:
> I'm developing a simple client - server application and what I want is to
> automatically reload classes on server side when I change them, I don't
> want to restart my server all the time.
This has been covered far too often for me to want to go into detail again, but
broadly you have to look into using your own classloader(s). Use your own
explicitly created classloader to load your "hot swappable" classes. When you
want to reload, discard all references to that classloader, the classes it
loaded, and any instances they may have. Reload by creating a new classloader
and using it to load the new class defintions.
-- chris