How do I package a web fragment in a jar with Netbeans and Maven

4.8k views Asked by At

When selecting a new maven project from the Netbeans New Project Menu, there is the option to create a Web Application, or a Standalone Application. I'd like to create a Class Library for use with a Web Application.

How would you recommend I go about this. I see the new Servlet 3.0 Web Fragments need to be put into the META-INF folder and saved as web-fragment.xml. I'm not too sure where I'd create this directory if I'm packing a JAR and a WAR.

Some insight would be greatly appreciated.

2

There are 2 answers

0
Ravi Kadaboina On BEST ANSWER

You can create either Java application or Web Application. Just place the META-INF folder in the src/main/resources folder. and place web-fragment.xml directly under it. You can also place any images,css or javascript files in META-INF/resources folder. So when the application you are deploying this for will look in the WEB-INF/lib folder and load all the META-INF contents of the jar onto the classpath.

0
electrobabe On

when generating the .war file with standard maven settings (no special config of maven-plugin-war) the web-fragment.xml should found in the /META-INF dir of the generated JAR file inside the WAR's /WEB-INF/lib dir.

in our case the web-fragment.xml was not in this dir but in the WAR's /META-INF dir, which is the wrong place