Creating web fragment projects

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 using 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

  1. In the Java™ EE perspective, select File > New > Project... > Web > Web Fragment Project > Next. The web fragment wizard opens.
  2. In the Project name field, type a name for the web fragment project. To change the default Project location, clear the Use default location checkbox and 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.

  3. The Target runtime field is pre-populated with the selection from the enterprise project.
  4. Optional: Select a pre-defined project configuration from the Configuration drop-down list.
  5. Optional: If you want to modify the configuration details, click Modify:

    Modify configuration

    • 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 OK.
  6. Optional: Select the Add project to Dynamic Web project check box to add the new module to a web archive (WAR) project. Type a new dynamic web project name or select an existing project from the drop-down list in the Dynamic Web project name combination box. Or, click New to launch the Dynamic Web Project wizard.
  7. 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. Click Next.
  8. 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).
  9. In the Default output folder field, specify a folder for your output files or accept the default value (bin), and click Finish.
  10. In Enterprise Explorer view, you see the resulting web fragment project folders:
    Web fragment project folders
Icon that indicates the type of topic Task topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: tcreatwebfragment.html