Category Archives: JavaEE

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


Web Application with JAX-RS (Jersey) on Glassfish

In this tutorial we create a minimalistic web application by using JAX-RS annotations. Our provider class contains some simple methods, responding to HTTP GET requests:

    public class Resource {

        public String hello() {
            return "Hi from REST!";

        public String shortWelcome(@PathParam("name") String name) {
            return "Hi, " + name;

To hold the Web Service configurations we need to create a class which extends

package com.mycompany.restdemo;


public class ApplicationConfig extends Application {

To map the incoming requests under this application, annotate the class with Finally by overriding the

public Set<Class<?>> getClasses()

method of the class return the provider class(es). This will make the methods of the provider class visible under rest/welcomes/hello and rest/welcomes/short/name URLs.

package com.mycompany.restdemo;

import java.util.Set;

public class ApplicationConfig extends Application {
    public Set<Class<?>> getClasses() {
        return getRestResourceClasses();
    private Set<Class<?>> getRestResourceClasses() {
        Set<Class<?>> resources = new java.util.HashSet<Class<?>>();
        return resources;

Your Web Service is done!

Here is the archive containing this demo project tested in GlassFish 3.1.2. It’s a maven project and you can run it right after extracting (you will need Maven) by executing:

mvn install

in the same folder where the pom.xml file is. This will download the required libraries and deploy the web application under http://localhost:8080/restDemo

restDemo.tar.gz (1.59 KB)