Run your web code from your IDE

Many Java developers complain about the length of time it takes to deploy their webapps for development, or to start the embedded WebTools server in Eclipse, or to use the mvn jetty:run process with Maven.

At work, we’ve created a solution using class which starts up Jetty and gets it to serve your webapp from within the IDE. This means you have start up times of seconds, and can debug without using remote debugging.

Happily, we’ve been able to open source this, too, so people can try it for themselves rather than just here me talk about it.

The source code is here, but you are probably better off using Maven, adding the following repository to your pom.xml:


<repository>
<id>EdAuUtil</id>
<url>http://maven.uat.educationau.edu.au/EdAuUtil</url>
</repository>

and adding the following dependencies:

<dependency>
<groupId>au.edu.educationau.opensource</groupId>
<artifactId>EdAuUtils</artifactId>
<version>0.9</version>
</dependency>

<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>6.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>jasper</artifactId>
<version>6.0.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-ant</artifactId>
<version>0.8</version>
<scope>test</scope>
</dependency>

Then you can run the class au.edu.educationau.opensource.devsupport.TestWebServer from your IDE. I need to generate the javadocs and put them up somewhere, but for the moment the code is reasonably well documented.

5 thoughts on “Run your web code from your IDE

  1. Interesting, but if we have a war project (maven), for example in netbeans (I use the version 6), how to execute the class since it is web project and we need a container?
    Sorry, it can be fool question, but the only way I know to run this class is in the own maven, isn’t it?
    Sorry again, can you help?
    Thanks,
    Gilberto

  2. @Gilberto – you just run this class like it is a normal Java program

    @dmitri – I haven’t looked at jettylauncher, but it does look to beabandoned now.

  3. I’m running it through maven:

    org.codehaus.mojo
    exec-maven-plugin

    java
    au.edu.educationau.opensource.devsupport.TestWebServer

    But I’m getting this error:
    No goals needed for project – skipping
    [exec:java]
    ————————————————————————
    [ERROR]BUILD ERROR
    ————————————————————————
    null

    org/mortbay/jetty/Server
    ————————————————————————
    For more information, run Maven with the -e switch
    ————————————————————————
    Total time: 12 seconds
    Finished at: Wed Jan 30 15:07:08 BRT 2008
    Final Memory: 65M/142M

  4. @Gilberto – it isn’t a Maven plugin. Just run it like you would a plain old java program. From the command line:

    java -cp (classpath here) au.edu.educationau.opensource.devsupport.TestWebServer

    Or run that class from your IDE (In Eclipse: Run->Open Run Dialog..->Double Click “Java Application” and enter au.edu.educationau.opensource.devsupport.TestWebServer as the main class)

Leave a Reply

Your email address will not be published. Required fields are marked *