Package JSF Flow in a JAR file

02 January 2015
By Gonçalo Marques
In this article we will see how to package a JSF Flow in a JAR file.


In the article JSF Flow example we have seen how to define a JSF Flow inside the same web application where it will eventually be used, basically by using the application's own folder structure.

In this article we will define that exact same flow but we will package it inside a JAR (library) file instead.

Note: The source code of the JAR packaged Flow contained in this article is available for download at the end of this page.

JSF Flow packaging in a JAR file

In order for a flow to be packaged in a JAR file it must follow some rules:

  • The flow definition bust be explicitly declared in the JAR file under META-INF/faces-config.xml
  • Every flow node (or view) must be declared in a directory which name is the same name of the flow, under META-INF/flows (ex: META-INF/flows/[FLOW_NAME])

With this set of rules in mind we may change the original flow definition to JAR packaging without much effort:

Project directory structure
Project directory structure

Note that the Order flow nodes (order*.xhtml) and the respective OrderBean are all defined in the com-byteslounge-jsf-flow project. This project will be included as a JAR file inside WEB-INF/lib directory of the web application project (com-byteslounge-jsf-war).

The Order flow will work exactly as the one we have previously defined by using the web application directory structure in JSF Flow example.

The source code is available for download at the end of this page.

Download source code from this article

Related Articles


About the author
Gonçalo Marques is a Software Engineer with several years of experience in software development and architecture definition. During this period his main focus was delivering software solutions in banking, telecommunications and governmental areas. He created the Bytes Lounge website with one ultimate goal: share his knowledge with the software development community. His main area of expertise is Java and open source.

GitHub profile:

He is also the author of the WiFi File Browser Android application: