你如何在EAR中部署一个WAR作为Glassfish中的根(/)上下文? [英] How do you deploy a WAR that's inside an EAR as the root (/) context in Glassfish?
问题描述
我有一个包含两个WAR的EAR文件war1.war和war2.war。我的application.xml文件如下所示:
<?xml version =1.0encoding =UTF-8? >
< application version =5xmlns =http://java.sun.com/xml/ns/javaeexmlns:xsi =http://www.w3.org/2001/XMLSchema-实例xsi:schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd\">
< display-name> MyEAR< / display-name>
< module>
< web>
< web-uri> war1.war< / web-uri>
< context-root> /< / context-root>
< / web>
< / module>
< module>
< web>
< web-uri> war2.war< / web-uri>
< context-root> / war2location< / context-root>
< / web>
< / module>
< / application>
这会导致war2.war在 http:// localhost:8080 / war2location ,这是正确的,但war1.war在 http:// localhost:8080 // - 注意两个斜线。
我在做什么错了?
请注意,包含在EAR中的WARs的sun-web.xml文件会被忽略。在Glassfish 3.0.1中,您可以在管理控制台中定义默认的Web应用程序:
Configuration \\\\\\\\\\\\\\\\\ \默认Web模块。
下拉框包含所有已部署的war模块。
默认的web模块可以从 http:// localhost:8080 / 。
I have an EAR file that contains two WARs, war1.war and war2.war. My application.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<application version="5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd">
<display-name>MyEAR</display-name>
<module>
<web>
<web-uri>war1.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module>
<web>
<web-uri>war2.war</web-uri>
<context-root>/war2location</context-root>
</web>
</module>
</application>
This results in war2.war being available on http://localhost:8080/war2location, which is correct, but war1.war is on http://localhost:8080// -- note the two slashes.
What am I doing wrong?
Note that the WARs' sun-web.xml files get ignored when contained in an EAR.
In Glassfish 3.0.1 you can define the default web application in the administration console: "Configuration\Virtual Servers\server\Default Web Module". The drop-down box contains all deployed war modules.
The default web module is then accessible from http://localhost:8080/.
这篇关于你如何在EAR中部署一个WAR作为Glassfish中的根(/)上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!