[opencms-dev] developing modules: how to quickly publish Java.class files?

Christian Steinert christian_steinert at web.de
Fri Feb 10 02:57:58 CET 2006


Hi,

I do the following in a small script, which I have configured as 
additional tool in eclipse, so I just run it from the menu, whenever I 
like (but you can also link your script to execute automatically after 
each build process, if you like).

my script does
- restart the opencms webapplication context by calling wget and trigger 
the URL-based tomcat admin to reload the opencms context
(wget also exists for windows - if you search, you'll probably find 
binarys somewhere, just as I have; or you ask me and I send them to you)
- then the script copies all of my re-compiled classes into the 
classes-directory of the Opencms Webapp

You don't need to use jars and you don't need to upload any classes/jars 
into the VFS, before your module is really to be given away for others.
The Java VM loads classes from the real Filesystem anyway, so why bother 
with VFS, while still developing.
Just make sure, that your classes appear at only one location in the 
classpath, as I said, I use the classes directory of OpenCms.

When I have copied the new classfiles the classfiles, I have a complete 
login bookmark in my browser. That bookmark already contains username 
and password and I can even leave my old cms window open.

It's still a bit annoying, but replacing the classfiles will only work 
together with restarting the webapp. And if you restart the webapp, then 
of course you have to login again.

__

Another thing is very handy, too:
- turn your Java engine into debug mode.
- connect with the eclipse debugger to the running engine
- debug as much as you like;
- even if you don't really debug:
if you change and compile some classes now, while the debugger is 
connected, then your modified classes get injected into the running 
instance.

Of course, if you shutdown and restart your java instance, then the 
classes are loaded again from the classpath, so the hot insertion 
through this method lasts only as long as the classes are held in memory.
But until then, the hotly inserted versions are used immediately, 
without restarting anything.

The only thing (according to my experience is): don't re-compile (which 
in this case means: don't cause a re-injection of classes), while at the 
same time your program is waiting at a breakpoint.
Instead: let the program run through again, until it doesn't wait at any 
breakpoints anymore and then you can re-compile (and thereby re-inject) 
your modified classes.

Your new class versions take over immediately with the next request.

Regards
Christian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060210/2a490a5b/attachment.htm>


More information about the opencms-dev mailing list