5

We recently switched to Glassfish 3.1.2.2 and have several Web-Applications packaged as war files. At times the desired context-root for these applications differs from the filename.

Back when we used Weblogic we achieved this by declaring the context-root in the weblogic.xml like this

<context-root>path/to/our/App</context-root>

We noticed that the same Tag exists in the glassfish-web.xml. But no matter what we define there, the server always determines the filename as the context-root.

Now we find the option --contextroot in the asadmin utility that would allow us to overwrite the filename at deploy time, but we'd prefer to do define it directly in the archive itself so that whoever will deploy it in the end won't need to know the desired contex-root.

Is there any way to achieve this?

4

2 回答 2

10

在 GlassFish 3 和 GlassFish 4 中,Web 应用程序的配置是通过glassfish-web.xml. 在您的情况下,所需的配置文件如下所示:

<!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>
    <context-root>/path/to/our/App</context-root>
</glassfish-web-app>

您可以在Oracle GlassFish Server 应用程序部署指南的GlassFish Server 部署描述符文件部分找到更多详细信息。本文档的在线版本可在http://docs.oracle.com/cd/E18930_01/html/821-2417/上找到。

于 2013-08-21T13:22:46.937 回答
4

通常这应该glassfish-web.xml看起来像这样:

<!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>
    <context-root>/path/to/App</context-root>
</glassfish-web-app>

但是在这里,您似乎需要一个sun-web.xml为您的任务调用的文件。

这是一个例子:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC 
     "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN"   
     "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app error-url="">
    <context-root>/path/to/our/App</context-root>
</sun-web-app>
于 2013-04-25T15:34:59.203 回答