views:

34

answers:

3

Out project uses WebLogic as web-server and uses mostly JSP for user interface. With standard setup it is possible to copy edited JSP files into the exploded deployment directory and WebLogic will automatically pick them up, recompile and serve new content through HTTP. However, is it possible to avoid copying at all, so that I just save a file in my editor and it is immediately (well, after a couple of seconds for recompilation) visible?

The project uses Apache Ant as building tool. I would imagine what I want would be possible with symlinks (since this is for deployment only I don't care about cross-platformity), but then I don't see how it is possible to symlink lots of files at once with Ant.

So, how do I achieve save-JSP-hit-F5-in-browser functionality either

  • with some setting in WebLogic; or
  • with symlinking JSPs using Apache Ant (instead of copying them as is done now); or
  • something else completely?
+1  A: 

You can put all your JSP files under a jsp folder and then symlink that folder into your WEB-INF folder in the exploded deployment directory.

Ant has an optinal task for creating single symlinks. The task can kind of create directories of symlinks, but works by recording what symlinks are there and then later re-creating those at a later time. (E.g. you could use shell script to initially create your symlinks in your jsp source, use Ant to record the links created, which is stored in a text file with your source folder, and then use this text file to later recreate the links.)

http://ant.apache.org/manual/OptionalTasks/symlink.html

mdma
I cannot. This is a large and convoluted project and reorganizing its structure is not feasible. Any better idea than symlinking 30 or so toplevel JSP directories to deployment directory individually?
doublep
I've made an edit to my suggestion. How about creating a shell script to do the linking? Another alternative is to amend the build to create the exploded webapp around your source directory structure, if you can run the webapp locally.
mdma
If there's a simple way to call a shell script from Ant, then why not? I just don't want to make it cumbersome — I already invoke Ant to build the project, so I'd prefer a solution that didn't require changing build command line.
doublep
Ant has an exec task that can be used to invoke system commands/shell scripts. See http://ant.apache.org/manual/CoreTasks/exec.html
mdma
@mdma: Thanks, that's (exec) is what I eventually settled upon.
doublep
A: 

A cron job could be setup to watch the source directories of your JSP files and copy them to the target directory on the server. Continuous Integration tools do this sort of thing to have builds triggered by the checkin of code. SourceForge has a server that does it and CruiseControl is another.

Kelly French
You probably misunderstood, I need this for development. And a changed file should be picked up by WebLogic in some 5 seconds, so I guess it would be a pretty resource-heavy task for cronjob.
doublep
CruiseControl is used in development. I mentioned it as an alternative to the ANT discusion. Not sure how resource-heavy a cronjob would be, depends on how its written of course. If you're using Eclipse, have you thought about a custom Builder that you could add to the build steps?
Kelly French
A: 

In the end, I had to use Ant's exec tool, because its symlink is very inconvenient. Additionally, delete follows symbolic links by default, which I find a horrible design decision (luckily I didn't delete anything not recoverable from VCS). If it is instructed to not follow links, then it doesn't delete them either (there's a flag for it in 1.8 but I have to use an older version). So, I had to replace clean target's delete with exec that essentially just runs rm -r — it is easier than 20+ lines of Ant mumbo-jumbo.

Also, if anyone is going to do something similar: don't forget to use -t option to ln if creating symlinks to directories. Otherwise, a repetetive run will create another link inside the directory symlink points to.

All in all it is working now, but I'm disappointed with Ant. I guess this all comes from Java's absent symlink support, but still...

doublep