I've been trying to understand web-fragment.xml, which is part of the Servlet 3.0 specification. The confusion comes from the discussion in this issue in NetBeans Issuezilla:
There it is posited that a web-fragment.xml file makes sense "in a project in which a web framework or a support web library is being developed". Similarly, in Arun Gupta's introduction to web-fragment.xml in a Maven-Wicket application (here), he ends by saying: "It would be nice if the next version of wicket-*.jar can include “META-INF/web-fragment.xml” then everything will work out-of-the-box."
In other words, the idea appears to be that the provider of a web framework library (e.g., the provider of Wicket, the provider of Struts, the provider of JSF), will be providing a web-fragment.xml file inside the Wicket/Struts/JSF library.
However, let's take a look at the content of a web-fragment.xml file obtained from Arun's blog entry, below. Here you can see that the application class name is defined within the web-fragment.xml file:
However, isn't the application class name defined per application, rather than per web framework library? To use the web-fragment.xml file that Arun provided, I needed to change the package naming and class name of the Wicket application class in my own application. That can't be right.
I imagine that the web-fragment.xml file should, somehow, be defined per application. So, if NetBeans IDE only lets me create such a file within a Java SE library project, doesn't that mean that I should be defining my entire Wicket application within a Java SE project? Then one would be modularizing the web.xml file, with each fragment being provided by a different JAR, with each JAR contributing a framework-specific part of the application. But that, according to the NetBeans Issue above, is not the idea at all.
Though I feel that the web-fragment.xml file should be defined within a web application, it appears that only JAR files packaged in WEB-INF/lib are scanned for META-INF/web-fragment.xml, i.e., WAR files are not searched for this file.
So either I don't get it or there's something odd going on. Probably I simply don't get it. Is there a real scenario anywhere where web-fragment.xml is demonstrated, i.e., where there is more than a single web-fragment.xml? (Though a real sample with even one single web-fragment.xml would be interesting to see.) Especially, where do web frameworks (e.g., Wicket, Struts, JSF) fit into the web-fragment world? (From this, it would appear that if I want to use a Wicket filter in a web-fragment.xml file, the whole Wicket application would be created in a JAR file, which means that Java SE Library projects in NetBeans IDE should let me add support for web frameworks to them.) I haven't found a relevant sample thus far.