Building a standard web project to host in Apache Karaf
As building a standard web application and WAR isn't really in the scope of this book, the focus of this recipe lies on the transformation of a standard WAR into a WAB.
Getting ready
The sample code for this recipe is available at https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter4/chapter4-recipe6.
How to do it…
Transforming a standard WAR project into a WAB is simple. So, let's take a look at the specialties around WAR and WAB files. For simplicity, let's call this project web project from here on.
Contrasting with a standard bundle project, where the classes reside directly in the JAR file, the classes of a web project should be contained in the classes
folder under the WEB-INF
folder. The same is true for embedded libraries; in a web project, these libraries are required to be placed in the lib
folder under the WEB-INF
folder.
Note
Beware—embedding other JAR files should be done only if the JAR file is needed internally...