There are a few specifics to consider when you develop a web-enabled OSGi application, especially if your application uses the Servlet 3.0 or Contexts and Dependency Injection (CDI) capabilities of the Java™ Platform, Enterprise Edition 6 (Java EE 6) specification.
Any files that are in the root directory of a web application can be viewed or downloaded using a browser. To prevent your bundles and bundle fragments from being accessed in this way, you should keep your .class files in a subdirectory such as WEB-INF/classes, and your .jar files in a subdirectory such as WEB-INF/lib, rather than in the root of the bundle.
You can extend bundles by adding bundle fragments. However you cannot control the order in which bundle fragments are attached.
To support the Java Servlet 3.0 specification, this implementation lets you define a web application through annotations in bundles and bundle fragments, as well as (or instead of) through a web.xml file for the application. The configuration for a web application is built by scanning its class path for annotations, and the order of components on the class path depends upon the fragment attach order.
Because you cannot control the order in which bundle fragments are attached, you cannot predict the order of items on the class path. This means that the design for your web application must not rely on bundle fragments being attached in a particular order.
The Java Servlet 3.0 specification lets you use web fragments to define the class path order. For OSGi applications, the bundle class path is the primary mechanism for specifying the ordering of components. If you use the Java Servlet 3.0 ordering capabilities for web fragments, you must ensure that the resulting class path order matches the bundle class path.
BundleClassPath:WEB-INF/myclasses,WEB-INF/yourclasses.jar,
WEB-INF/hisclasses,WEB-INF/herclasses.jar
For CDI to work with a class WEB-INF/myclasses/a.class,
you need to add the file WEB-INF/myclasses/META-INF/beans.xml.
Similarly, for CDI to work with a class WEB-INF/herclasses.jar/b.class,
you need to add the file WEB-INF/herclasses.jar/META-INF/beans.xml.