Gretty supports JEE annotations out-of-the-box. This means: you don’t have to configure anything, you just use JEE annotations in the web-app:

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet( name="AnnotatedServlet", displayName="Annotated Servlet", urlPatterns = {"/annotations/*"}, loadOnStartup=1)
public class ExampleServlet extends HttpServlet {

  private static final long serialVersionUID = -6506276378398106663L;

  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // doGet implementation

Note that jetty7 flavor of Gretty does not support JEE annotations, since it is using servlet-api 2.5.

jetty8, jetty9, tomcat7, tomcat8 flavors of Gretty support JEE annotations in the current web-app and in it’s overlays (if any).

Normally Gretty looks for JEE-annotated classes in "build/classes" directories belonging to the web-app classpath. You can change this behavior by inserting the following into "jetty-env.xml" (if you run on jetty):

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Call name="setContextAttribute">

in the example above we specify, that Gretty should scan for annotations any jar whose name starts with "foo-" or "bar-", or a directory named "classes".