Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
735 views
in Technique[技术] by (71.8m points)

war - Using the context-root from glassfish-web.xml in GlassFish 3

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In GlassFish 3 and GlassFish 4 the configuration of a web application is done via glassfish-web.xml. In your case the desired configuration file would look 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/our/App</context-root>
</glassfish-web-app>

You can find further details in section GlassFish Server Deployment Descriptor Files of Oracle GlassFish Server Application Deployment Guide. A online version of this document can be found at http://docs.oracle.com/cd/E18930_01/html/821-2417/.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...