...
Add the following to the <build><plugins>
block of your projects pom.xml
Code Block |
---|
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> </plugin> |
Running
In order to run Jetty on a webapp project which is structured according to the usual Maven defaults, you don't need to configure anything.
...
First set MAVEN_OPTS environment variable with the following command:
Code Block |
---|
export MAVEN_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,address=87874000,server=y,suspend=y' |
After setting this property, run "maven jetty:run" and it will block, waiting for a debug connection. If "suspend=n" is set, it will start right away.
...
As above the jvm will start right away when "suspend=n" is set.
Attaching to the server running in debug mode
...
Using Eclipse:
Running Eclipse Open "Run --> Debug... --> Remote Java Application". Press "New launch configuration". Fill in the dialog by selecting your webapp project for the "Project:" field, and ensure you are using the same port number as you specified in the address= property above.
...
This article is a gathering of information, credits need to be given to the authors of the pages behind the given links.
Using Netbeans (thanks to mrhaki)
This setup will also allow you to debug your application under Netbeans.
Pom setup
Add the following to the <build><plugins>
block of your projects pom.xml
Code Block |
---|
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<stopPort>9966</stopPort>
<stopKey>jetty-stop</stopKey>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
|
The stopPort and stopKey parameters can have arbitrary values.
Configure custom Run and Debug actions
Open the properties window of your Maven project and select Actions from the Categories list.
Find the Run action and change the Execute Goals value to jetty:stop jetty:run
.
Then, do the same for the Debug project action and set the following properties:
Code Block |
---|
jpda.listen=maven
netbeans.deploy.debugmode=true
|
That's all!