Configure Maven to run Jetty
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.24</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<!-- Use whatever you want the http port to be -->
<port>8080</port>
</connector>
</connectors>
<userRealms>
<userRealm implementation="org.mortbay.jetty.security.HashUserRealm">
<name>default</name>
<config>src/main/resources/jetty-realm.properties</config>
</userRealm>
</userRealms>
<!-- If you plan on changing this file during execution, turn the scan interval higher than 0 -->
<scanIntervalSeconds>0</scanIntervalSeconds>
<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
</configuration>
</plugin>
You will need a jetty-realm.properties file and a webdefault.xml file.
jetty-realm.properties:
user1: pass1,role1
user2: pass2,role2
webdefault.xml:
Mine looks like the "JSP configuration" section
Setup Start Server Command
- Run -> External Tools -> External Tools Configuration
- Right Click Program -> New
- Name: Whatever
- Location: Browse to your mvn executable
- Working Directory: click Browse Workspace button and select ${YOUR_WEB_PROJECT}
- Arguments: jetty:run
- Click Environment
- Click New
- Enter a variable names MAVEN_OPTS and set it to "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
Setup Remote Debugging
- Run -> Debug Configurations
- Right Click Remote Java Application -> New
- Name: Whatever
- Project: ${YOUR_WEB_PROJECT}
- Connection Type: Standard (Socket Attach)
- Host: localhost
- Port: 8787
- Also click "Allow termination of remote VM". It's going to be the only way to elegantly kill your Jetty server without opening the task manager.
Usage
- Start the server using the external tools
- Start the remote debugging once the server is up
- Open up the debug perspective -> Right click the VM and click terminate to kill the server
No comments:
Post a Comment