4

So I'm trying to get hot deploy to work on my maven project using netbeans. I have two war packages. One I call "web" and the other I call "custom-web". I overlay (with the maven overlay plugin) "custom-web" on top of "web". I have several "custom-web" projects, one for each of my clients. So maven overlays were a good fit for my needs.

The problem is I really, really want to get hot deployment of classes and static files (.js, .css) on both projects. But the hot-deployment only works on the "custom-web" projects, if I modify a class or static file on "web" the changes are not reflected on the server unless I manually rebuild "web" and do a redeploy of the whole application which can take from 3 to 5 minutes, severely hindering my development.

I'm using Netbeans with the "deploy on save" option and the "apply code changes" when in debug mode. Both do not work on "web" files/classes.

I'm looking for a solution. My custom-web project will mostly have static files, but it can also have classes. It does not need to use overlays necessarily, but I can't figure out any other way to properly add two projects together without using overlays.

Hoffmann
  • 14,369
  • 16
  • 76
  • 91
  • Good question. This has worked out-of-the-box for me when using STS 2.9+ on Windows7 when both 'web' and 'web-overlay' projects are open and am running webapp using a Tomcat or tcServer inside STS. I think it is the WTP eclipse plugin specifically that does the overlaying magic. However exact same setup on LinuxMint does NOT work (does not do the overlay). – sbk Mar 20 '13 at 15:58
  • @sbk I'm using netbeans with glassfish. I'm open to changing servers but not the ide. – Hoffmann Mar 20 '13 at 16:17
  • Fair call. Just saying what worked for me. – sbk Mar 20 '13 at 16:23

2 Answers2

1

Not sure whether that's an option, but using Jetty works great in this case. Using the jetty:run goal, you can point Jetty to the source directories to watch (across projects), and Jetty will always serve the files from there.

In your case, you would point Jetty's scanTargets to your source directories, and Jetty will serve the files from there.

See http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#jetty-run-goal for configuration options and an example.

nwinkler
  • 52,665
  • 21
  • 154
  • 168
  • sounds interesting, I will try that. How is j2ee support on jetty? I'm using a lot of j2ee stuff (ejbs, managed beans, jsf and such) – Hoffmann Mar 20 '13 at 14:22
  • I have used some of that on Jetty, e.g. JSF, but I haven't tried to deploy any EJBs on there. – nwinkler Mar 20 '13 at 14:27
  • 1
    Here's a link to another question mentioning running Geronimo on top of Jetty for EJBs: http://stackoverflow.com/a/9024108/1228454 – nwinkler Mar 20 '13 at 14:27
  • You known any other application servers that support that scanTagets option or a similar option? – Hoffmann Mar 20 '13 at 14:28
  • Sorry, I'm only aware of Jetty with this feature. – nwinkler Mar 20 '13 at 14:41
0

Maven profile (http://maven.apache.org/guides/introduction/introduction-to-profiles.html) is maybe a solution. You can create a "dev" one with your "web" project having dev configurations and "deploy on save" stuff.

In netbeans, you can map configurations with profiles : http://wiki.netbeans.org/MavenBestPractices#Configurations

Finally use the overlay options for your customized projects and your CI server.

lforet
  • 16
  • 2