在GlassFish 3中使用来自glassfish-web.xml的上下文根 [英] Using the context-root from glassfish-web.xml in GlassFish 3

查看:396
本文介绍了在GlassFish 3中使用来自glassfish-web.xml的上下文根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我们转向了Glassfish 3.1.2.2,并将几个Web应用程序打包成战争文件。有时这些应用程序所需的上下文根不同于文件名。



当我们使用Weblogic时,我们通过在weblogic.xml中声明context-root来达到此目的。

 <上下文根>路径/到/我们的/应用< /上下文根> 

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

现在我们在asadmin实用程序中找到选项--contextroot,它允许我们在部署时覆盖文件名,但是我们希望直接在归档本身,以便最终部署它的人不需要知道所需的contex-root。



有什么方法可以实现这一目标?

解决方案

通常这应该与> glassfish-web.xml 一起使用,如下所示:

 <!DOCTYPE glassfish-web-app PUBLIC 
- // GlassFish.org //DTD GlassFish应用程序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.0encoding =UTF-8?> 
<!DOCTYPE sun-web-app PUBLIC
- // Sun Microsystems,Inc. //DTD GlassFish Application Server 3.0 Servlet 3.0 // EN
http:// www .sun.com /软件/应用服务器/ DTD的/太阳网络app_3_0-0.dtd>
< sun-web-app error-url =>
< context-root> / path / to / our / App< / context-root>
< / sun-web-app>


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?

解决方案

Normally this should work with a glassfish-web.xml looking like this:

<!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>

But here it looks like you need a file called sun-web.xml for your task.

Here is an example:

<?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>

这篇关于在GlassFish 3中使用来自glassfish-web.xml的上下文根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆