So I’ve been (slowly) working on converting my budgeting app from Python/Django to Java. I really like Django, but this web app doesn’t really fit in the Django paradigm the way I initially thought. Oh well, it’s a good opportunity to do more programming.

Anyway, as I have been doing the migration I decided to use RESTEasy to do the URL mapping. I’m a big fan of pretty URLs for any site, and RESTEasy makes the whole process nice and easy (or so I thought).

I decided that the nice way to go was with a completely annotation based system (CDI with annotations and RESTEasy Path annotations). Unfortunately the RESTEasy documentation doesn’t do a good job of documenting how to run with both a servlet filter,¬†and¬†annotations (you’ll see their example web.xml snippet has the servlet filter with a JAX-RS Application class). The documentation does say that you can add a configuration switch to have RESTEasy scan for annotations, but it lists them as context-params for the servlet based approach.

After trying a number of different combinations without any luck, I went the debugging route. Slapping the RESTEasy source in my Eclipse project, I ran through the code to find where the configuration switches were loaded with the servlet filter. Luckily it didn’t take too long to find that context-params can be translated to init-params inside the filter element. This resulted in the following:

<filter>
 <filter-name>Resteasy</filter-name>
 <filter-class>org.jboss.resteasy.plugins.server.servlet.FilterDispatcher</filter-class>
 <init-param>
 <param-name>resteasy.scan</param-name>
 <param-value>true</param-value>
 </init-param>
</filter>

<filter-mapping>
 <filter-name>Resteasy</filter-name>
 <url-pattern>/*</url-pattern>
</filter-mapping>