views:

289

answers:

6

I've set up a simple Eclipse 3.5/Jetty 6.1 web app which returns hello world. It works. This is on Windows and uses the "Jetty Generic Server Adapter". I have auto deployment working so that it deploys after changes periodically.

How do I go about setting it up so that if I change any static content it doesn't have to redeploy i.e I can just hit F5 to see the changes straight away. For minor HTML changes it's quite unusable waiting 20-30 seconds for a deployment.

A: 

Duplicate..sort of http://stackoverflow.com/questions/347698/how-do-i-automatically-export-a-war-after-java-build-in-eclipse

ring bearer
First, that should have been posted as a comment. Second, that is a completely different subject?
BalusC
+3  A: 

I haven't used Jetty before, so I can't tell from experience if that long deployment times are normal nor how to optimize it. But I would just inform that this is dependent on the server and the server plugin used. In case of Apache Tomcat 6 + Eclipse-provided plugin and Sun Glassfish v3 + GF-provided plugin the auto deployments are fast enough. Especially Glassfish v3, which is relatively slow on startup, really excels with sub-second (hot)deployments.

First step would be to check if there are alternative Jetty Eclipse plugins and then try them and/or if there is a setting to lower the hotdeploy scan interval.

BalusC
Ha, similar experience here (+1) :-)
Chris Lercher
I've installed glassfish v3 and the glassfish plugin. It's not instant but it's fast enough. Thanks for the help!
ChrisSmith..zzZZ
You're welcome.
BalusC
A: 
  1. I found, that the time it takes to auto deploy depends greatly on the application server. I haven't done auto deployment with Jetty, but the difference between JBoss (>10 sec) and Glassfish (< 3 secs) is significant.

  2. You could link the static directory of your application server into the Eclipse workspace. This way, you would edit the files directly in that directory.

Here's how to create such a link: New > Folder > Advanced > Link folder in the file system

Chris Lercher
A: 

The problem you're describing might be this one. It is a known problem that static files are locked in Jetty on Windows - which might force you to redeploy. Normally you can just edit your files, you don't have to redeploy anything to see your changes. It works even with class modifications (well, to some extent).

This is the third time I advertise it today, but here's my approach for Jetty-based testing: Hifaces20 Testing.

ps. Hifaces20 Testing does not suffer from the file locking problem, it implements the suggested workaround.

lexicore
But if a file is locked, the OP wouldn't be able to save it and it would have produced an error?
BalusC
@BalusC: Not sure. I just remember that this problem forced be to restart Jetty all the time back then.
lexicore
+1  A: 

For minor changes in classes it's also possible with tools like http://www.zeroturnaround.com/jrebel/

Sebastien Lorber
+1  A: 

I use maven with configuration below

        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.25</version>
            <configuration>
                <scanIntervalSeconds>1</scanIntervalSeconds>
                <requestLog implementation="org.mortbay.jetty.NCSARequestLog">
                    <append>true</append>
                </requestLog>
            </configuration>
        </plugin>

so jetty scans for changes every second, and for my simple application it takes about 200ms to restart app. I noticed that sometimes yetty does not sees changes in jsp files

Maciek Kreft
I had the same problem with Yetty. Thanks for the reply - works well enough for me. Much better than the 10 seconds it takes to recompile an ASP.Net app.
ChrisSmith..zzZZ