使用GlassFish 3中glassfish-web.xml的context-root

Mar*_*kus 5 glassfish war contextroot asadmin

我们最近切换到Glassfish 3.1.2.2并将几个Web应用程序打包为war文件.有时,这些应用程序的所需上下文根与文件名不同.

回到我们使用Weblogic时,我们通过在weblogic.xml中声明context-root来实现这一点

<context-root>path/to/our/App</context-root>
Run Code Online (Sandbox Code Playgroud)

我们注意到glassfish-web.xml中存在相同的Tag.但无论我们在那里定义什么,服务器总是将文件名确定为context-root.

现在我们在asadmin实用程序中找到了选项--contextroot,它允许我们在部署时覆盖文件名,但我们更愿意直接在存档本身中定义它,以便最终部署它的人不会需要知道所需的contex-root.

有没有办法实现这个目标?

Oli*_*ver 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>
Run Code Online (Sandbox Code Playgroud)

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

  • 是的,我有类似的问题.`sun-web.xml`对上下文根没有影响.我改为使用`glassfish-web.xml`.有用. (2认同)

unw*_*ich 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>
Run Code Online (Sandbox Code Playgroud)

但在这里,您似乎需要一个sun-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>
Run Code Online (Sandbox Code Playgroud)