1) Try editing web.xml outside of NetBeans first then continue with developing the application and deploying
or
2) The basic idea is re-arranging the web.xml and sun-web.xml files between the build and the deploy steps, taking advantage of the overrideable ANT tasks that VWP makes available. The example below is for adding a reference to a custom datasource.
a) isolate the XML fragment to be added to web.xml, and its final position:
<resource-ref> <description>Database</description> <res-ref-name>jdbc/MyDb</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref>must be inserted in the NetBeans-generated web.xml immediately BEFORE the closing </web-app> tag.
b) isolate the XML fragment to be added to sun-web.xml, and its final position:
<resource-ref> <res-ref-name>jdbc/MyDb</res-ref-name> <jndi-name>jdbc/MyDbRef</jndi-name> </resource-ref>must be inserted BETWEEN the </context-root> and the <class-loader ...> tags.
c) create a properties file to map string replacement rules. Name the file res-ref.properties and put it in the web/WEB-INF directory of your VWP project:
sunweb=</context-root>\n<resource-ref><res-ref-name>jdbc/LucyStarDb</res-ref-name><jndi-name>jdbc/LucyStarSvil</jndi-name></resource-ref> web=<resource-ref><description>Database</description><res-ref-name>jdbc/LucyStarDb</res-ref-name><res-type>javax.sql.DataSource</res-type><res-auth>Container</res-auth><res-sharing-scope>Shareable</res-sharing-scope></resource-ref>\n</web-app>
d) edit the project's build.xml and add the following ANT code: <!-- useful shortcuts for filenames --> <property name="prj-web-xml" value="build/web/WEB-INF/web.xml" /> <property name="prj-sun-web-xml" value="build/web/WEB-INF/sun-web.xml" /> <property name="prj-res-ref-props" value="build/web/WEB-INF/res-ref.properties" /> <!-- define a property to be set and true when web configuration files are missing --> <condition property="missing-web-files"> <and> <not><available file="${prj-web-xml}"/></not> <not><available file="${prj-sun-web-xml}"/></not> </and> </condition> <!-- define a property to be set and true when web configuration files are NOT missing --> <condition property="avail-web-files"> <and> <available file="${prj-web-xml}" /> <available file="${prj-sun-web-xml}" /> </and> </condition> <!-- define a property to be set and true when resource references are missing from configuration files --> <condition property="missing-resources"> <and> <available file="${prj-web-xml}" /> <available file="${prj-sun-web-xml}" /> <not> <isfileselected file="${prj-web-xml}"> <contains text="jdbc/MyDb" casesensitive="yes"/> </isfileselected> </not> <not> <isfileselected file="${prj-web-xml}"> <contains text="jdbc/MyDb" casesensitive="yes"/> </isfileselected> </not> </and> </condition> <!-- define a property to be set and true when resource refs MUST be added to configuration files --> <condition property="must-add-res-ref"> <or> <isset property="missing-web-files"/> <isset property="missing-resources"/> </or> </condition> <!-- override target post-init. This is just for debug, to check action flags ! --> <target name="-post-init"> <echo message="missing files = ${missing-web-files}" /> <echo message="available files = ${avail-web-files}" /> <echo message="missing refs = ${missing-resources}" /> <echo message="so, must add refs = ${must-add-res-ref}" /> </target> <!-- override target to re-process configuration files BEFORE creating the distribution .war Note that it is performed only if "must-add-res-ref" is set --> <target name="-pre-dist" if="must-add-res-ref"> <!-- in web.xml before /web-app --> <replace file="${prj-web-xml}" propertyFile="${prj-res-ref-props}"> <replacefilter token="&lt;/web-app&gt;" property="web"/> </replace> <!-- in sun-web.xml, between context-root and class-loader --> <replace file="${prj-sun-web-xml}" propertyFile="${prj-res-ref-props}"> <replacefilter token="&lt;/context-root&gt;" property="sunweb"/> </replace> </target> (Steps provided by user, p_repetti)