BriteSnow on Jetty – Quick Start Guide

Being a developer on a Java JEE project, words like increased productivity, faster development time, lightweight *, were always encouraging to me. I heard somewhere about BriteSnow company and their open-source products (they host them on github, which is very nice!) so I decided to give a shot to these tools and try to find out, could I really speed up the development process of an enterprise-size project.

Note that the first part of this guide is intended to provide a summary about (Brite)Snow configuration. Take it as a reminder or a cheat sheet. More detailed scenarios including persistence will follow soon and will reference this guide as a starting point.


Snow arrives through the following maven dependency. We are going to use the latest stable version, for experimental versions see their Maven section.


For the beginning create a standard servlet descriptor web.xml, in src/main/webapp/WEB-INF:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns=""

Note that the official documentation goes with servlet version 2.4 instead of 3.0.

Snow also requires a properties file to be present in the src/main/webapp/WEB-INF directory which in my case looks like:

# The Application Guice Modules (1 or more, comma seperated)

This may seem to be a bit tricky but it’s something similar when you configure a Jersey application through annotations. Except that in Jetty you can use the @ApplicationPath, but in this case you have to point to your application class in a separate config file (which is probably not as good as having only an annotation, but anyway..).

Beware, I made a mistake here! The documentation clearly says:

Note: The first Google Guice module defined in the snow.webApplicationModules property (here the only AppConfig ) specifies the base package from where Snow scans classes for Snow method annotations (e.g., @WebGet, @WebModelHandler, …) to do the appropriate “Web bindings.” So, make sure that the first Guice module is at the root package of your application.

First I placed the AppConfig into org.example.britesnowdemo.config (because I felt that should be OK, since I pointed to the right class in snow.webApplicationModules), sadly this made BriteSnow to answer with 404 to every request I made. So remember: your snow.webApplicationModules class should be always in the root package.

Our Snow application will be configured based on the modules present in this class:

package org.example.britesnowdemo.config;


public class AppConfig extends AbstractModule {

    protected void configure() {

For this example I’ll just leave this empty. You will probably have entities in your application, so take a look at the sampleBookmarks AppConfig on their github repository which shows a neat way to autodiscover all your entity classes:

That would be all regarding the configuration. Next thing to do is to create a simple web-service and finally fire some HTTP request.

Web Resources

If you’re already familiar with Jetty then you will find Snow almost identical, meaning web-method discoverage, similar method annotations, path annotations, etc.:

public Object aRestGet(@PathVar("id")Long id){
// id == 123

while in JAX-SR:

public Object aRestGet(@PathParam("id")Long id){
// id == 123

For the sake of simplicity our service will only say hi to us:

package org.example.britesnowdemo;

import com.britesnow.snow.web.param.annotation.WebParam;
import javax.inject.Singleton;

public class SnowResource {

    public String sayHelloTo(@WebParam("name") String name) {
        return "Hello, " + name + "!";

That’s all! Now you can deploy the project with Jersey’s maven plugin:

mvn jetty:run

and fire a HTTP request to the only existing REST resource:


You can download the full project from


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s