VWPUserFAQsavewebxmlJa
web.xml への変更が保存されません、解決方法はありますか。
1)まず、 web.xml を NetBeans の外で編集し、それからアプリケーションを開発、配備してみてください。
もしくは
2)基本的な考えはビルドと配備の間に web.xml と sun-web.xml ファイルを再調整します。VWPによって利用可能となるオーバーライド可能な ANT タスクを活用します。以下の例はカスタムデータストアに参照を加えるためのものです。
a) XML フラグを切り離し、web.xml に加えてください。そして、 </web-app> タグを閉じる前に NetBeans によって生成された web.xml 最後の位置に以下のコードを加えてください。
<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>
b) XML フラグを切り離し、 sun-web.xml に加えてください。そして XML フラグの末尾にある以下の部分を </context-root> と <class-loader ...> タグの間に加えてください。
<resource-ref> <res-ref-name>jdbc/MyDb</res-ref-name> <jndi-name>jdbc/MyDbRef</jndi-name> </resource-ref>
c) 文字列の再配置ルールを配置するためにプロパティファイルを作ってください。そのファイルを res-ref.properties と名前を付け、VWP プロジェクトの web/WEB-INF ディレクトリにおいてください。
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)プロジェクトの build.xml を編集し、以下の ANT コードを付け加えてください。(コード省略)
<!-- 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="</web-app>"
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="</context-root>"
property="sunweb"/>
</replace>
</target>
(p_repettiさんからの提供です)
- 日本語訳 : Mikiko Tsutsui
- 英文 (翻訳したバージョン: 1)
- 日本語 NetBeans Visual Web Pack ユーザー FAQ へ戻る

