Can't create glassfish-web.xml in my web project (Glassfish/Netbeans)

glassfish, jakarta-ee, java, netbeans, xml

Solution

This should work if you are using Netbeans 8. If you are using an older version of Netbeans you should update to the latest version.

You can manually create a new xml file named `glassfish-web.xml` (or rename the `sun-web.xml`) and insert the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
  <class-loader delegate="true"/>
  <jsp-config>
    <property name="keepgenerated" value="true">
    </property>
  </jsp-config>
</glassfish-web-app>

This is the content Netbeans creates by default.

Problem

I have a Java project that uses Java EE 7 and Glassfish 4.1 When I add a new Glassfish Descriptor to the project (via the right-click menu), it doesn't give me the ability to change the name of the `xml` file. It forces it to be `sun-web.xml` which is an old legacy format. I'm trying to use `glassfish-web.xml`. How can I make it add the correct file?

Original source