I have a full-fledged Java EE project running on GlassFish 4.1 / Java EE 7 (NetBeans 8.0.2) not using Apache Maven.
Depending upon the project functionality, the CDI dependency has to be added to both the projects/modules namely the EE module and the Web module (and a class library, if any).
I have been confusing for a long time seeing people recommending to add either "Java EE 7 API Library" or "Java EE Web 7 API Library" to the compile-time class-path as a CDI dependency (these libraries are bundled in NetBeans and readily available out of the box, when using NetBeans).
Since these libraries contain a collection of APIs possibly the entire Java EE stack starting from the Servlet API, adding one of these libraries to the compile-time class-path (especially in the EE project) does not make sense, when the CDI functionality is needed in Java EE applications.
Why is it suggested many a times especially in NetBeans projects to add one of these libraries, when only cdi-api.jar
as a CDI dependency is sufficient?
I do not find a canonical answer on this site nor somewhere else as to which library exactly is to be added in NetBeans projects, when the CDI functionality is required in Java EE applications. Adding only cdi-api.jar
goes fine, by the way.