Fork me on GitHub

n. Slang a rough lawless young Kuali developer.
[perhaps variant of Houlihan, Irish surname]
kualiganism n

Blog of an rSmart Java Developer. Full of code examples, solutions, best practices, et al.

Friday, April 30, 2010

Setting up Eclipse to use Jetty for KFS Development

Sometimes, you just want to use a straight, no-nonsense appserver for development. You want it to be fast, simple, and integrate with Eclipse and its debugger. Sounds like a tall order, but it's not. It's possible to setup Jetty to run KFS within Eclipse and hook in the debugger.

Move Required Libraries into Your KFS Project

The following need to be copied to the .classpath of your eclipse project
  • jetty-6.1.15.rc5.jar
  • jetty-util-6.1.15.rc5.jar
  • connector-1_5.jar

Create a Startup Server Class in Your KFS Project

Here's ours

package edu.arizona.jetty;

import org.mortbay.jetty.*;
import org.mortbay.jetty.webapp.*;
import org.mortbay.jetty.nio.*;

import static java.lang.System.getProperty;

* @author Leo Przybylski (
public class HappyMeal {
public static void main(String[] args) {
final String WEBROOT = getProperty("");
final int SERVER_PORT = Integer.parseInt(getProperty("jetty.port"));
final String CONTEXT_PATH = "/kfs-dev";

Server server = new Server();

Connector[] connectors = new Connector[1];
connectors[0] = new SelectChannelConnector();

WebAppContext webapp = new WebAppContext();

try {
catch (Exception e) {

Create a .launch for Jetty Server

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/kfs"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<listEntry value=""/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="edu.arizona.jetty.HappyMeal"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="kfs"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value=" -Djetty.port=8080 -Xmx2g -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Denvironment=dev -DlogDefault=WARN"/>

The parts to pay attention to are the org.eclipse.jdt.launching.MAIN_TYPE, org.eclipse.jdt.launching.PROJECT_ATTR, and org.eclipse.jdt.launching.VM_ARGUMENTS attributes. You'll need to adjust yours to your preferences.

Test it out

This will add jetty to the tools menu

Hooking up the Debugger

The jetty selection should now be available under the debug menu.


No comments:

Post a Comment