You can use the web fragment project wizard to create web
fragment projects in your workspace.
Before you begin
A web fragment is a logical partitioning of the web application
in such a way that the frameworks being used within the web application
can define all the artifacts without requiring you to edit or add
information in the web.xml. It can include almost all the same elements
that the web.xml descriptor uses, with these requirements:
- The top level element for the descriptor must be web-fragment
- The corresponding descriptor file must be called web-fragment.xml
If a framework is packaged as a JAR file and has metadata
information in the form of deployment descriptor, then the web-fragment.xml
descriptor must be in the META-INF/ directory of the JAR file.
A
web fragment is a mechanism for either defining or extending the deployment
descriptor of a web application by means of pluggable library JAR
files that contain both the incremental deployment information (in
the web-fragment.xml) and potentially any related or relevant classes.
The web fragment is also packaged as a library (JAR), with the web-fragment.xml
in the META-INF directory. Consequently, the web fragment project
is essentially a utility project, with the addition of a web fragment
facet to it. The web fragment facet enables you to add relevant context-sensitive
functionality to the fragment project.
Procedure
- In the Java™ EE perspective,
select . Alternatively, right-click the Enterprise Explorer
context menu, and select . The Web
fragment wizard opens.
- In the Project name field, type
a name for the web fragment project. To change the default Project
location, click the Browse button
to select a new location.
If you specify a non-default
project location that is already being used by another project, the
project creation fails.
- The Target runtime field is pre-populated
with the selection from the enterprise project.
- Optional: Select a pre-defined project configuration
from the Configuration drop-down list.
- Optional: If you want to modify the configuration
details, click Modify:
- Optional: Select one or more project facets
from the Project Facets list. To specify server
runtime environments, click Runtimes and select
one or more runtimes. After making your selections, you can save your
custom configuration by clicking Save.
- Optional: Select the Add project
to Dynamic Web project check box to add the new module
to an enterprise module (WAR) project. Type a new project
name or select an existing enterprise module project from the drop-down
list in the Dynamic Web project name combination
box. Or, click New to launch the New EAR module
Project wizard.
- Select Add project to working sets to
add the web fragment project to an existing working set, or click Select to
locate a working set, and click Next.
- On the Configure project for building a Java application page, on the Source
folders on build path field, click Add Folder... to
add folders for your source on the build path, or accept the default
value (src).
- In the Default output Folder: field,
specify a folder for your output files or accept the default value
(bin), and click Finish.
- In Enterprise Explorer view, you see the resulting web
fragment project folders: