Glassfish 3.1.2.2上Web应用程序的上下文路径 [英] Context path for web application on Glassfish 3.1.2.2

查看:189
本文介绍了Glassfish 3.1.2.2上Web应用程序的上下文路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法来明确指定部署到Glassfish 3.1.2.2的Web应用程序的上下文路径,但迄今为止我还没有运气。任何人都可以提供这方面的指导背景如下:

我有一个由两个独立的Netbeans(7.0)项目组成的Web应用程序。第一个是Web服务,称为FooWS。第二个是面向使用FooWS Web服务的Web应用程序的用户。它被称为FooApp。

我最近将glassfish升级到了3.1.2.2,希望解决一些其他问题,现在当我部署FooWS应用程序时,它将成功部署,但具有上下文路径/ web而不是/ FooWS。这不是我特别关心的事情,除非当我尝试部署FooApp时,glassfish也会尝试将它部署到/ web,导致出现以下错误:



SEVERE:加载应用程序时出现异常:java.lang.Exception:WEB0113:虚拟服务器[server]已经在[/ web]上加载了Web模块[FooWS];因此无法在此虚拟服务器上的上下文路径中加载Web模块[FooApp]。



FooApp的web.xml如下所示:

 < ;?xml version =1.0encoding =UTF-8?> 
< web-app version =3.0xmlns =http://java.sun.com/xml/ns/javaeexmlns:xsi =http://www.w3.org/2001/ XMLSchema-instancexsi:schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd\">
< context-param>
< param-name> defaultWebRootId< / param-name>
<参数值> 2631< /参数值>
< / context-param>

< listener>
< listener-class> com.foo.service.AppInitialiser< / listener-class>
< / listener>
< session-config>
< session-timeout>
30
< / session-timeout>
< / session-config>
< / web-app>

FooWS的配置类似。既没有提及应用程序上下文,所以我的期望是它应该使用/ FooWS而不是默认的/ web。

显而易见的解决方案似乎是重写web.xml中的上下文路径,但我找不到任何这样做的方法。有什么建议么?

只是一些跟进,我不小心将上下文路径更改为/ FooW。这次它按预期部署到/ FooW。如果/ FooWS导致旧行为返回,那么将其更改回来,也就是说,它会再次部署到/ web。似乎我现在有一个解决方法。

为了以后的任何人的利益,我在3.1.2中获得了相同的行为。我现在已经返回到3.1(b43),它的行为和预期的一样。

解决方案

添加glassfish-web.xml文件与web.xml相同的文件夹

 <!DOCTYPE glassfish-web-app PUBLIC -  // GlassFish.org //DTD GlassFish Application Server 3.1 Servlet 3.0 // ENhttp://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd\"> 
< glassfish-web-app error-url =>
< context-root> / FooWS< / context-root>
< / glassfish-web-app>


I'm trying to find a way to explicitly specify the context path of a web application being deployed to Glassfish 3.1.2.2 but I've had no luck so far. Can anyone provide guidance on this? The background to this is below:

I have a web application that consists of two separate Netbeans (7.0) projects. The first is a web service and is called FooWS. The second is a user facing web application which uses the FooWS webservice. It's called FooApp.

I've recently upgraded glassfish to 3.1.2.2 in the hope of resolving some other issue and now when I deploy the FooWS app, it deploys successfully but with the context path /web rather than /FooWS. This is not something I would particularly care about except that when I try to deploy FooApp, glassfish also tries to deploy that to /web leading to the following error:

SEVERE: Exception while loading the app : java.lang.Exception: WEB0113: Virtual server [server] already has a web module [FooWS] loaded at [/web]; therefore web module [FooApp] cannot be loaded at this context path on this virtual server.

The web.xml for FooApp looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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/web-app_3_0.xsd">
    <context-param>
        <param-name>defaultWebRootId</param-name>
        <param-value>2631</param-value>
    </context-param>

    <listener>
        <listener-class>com.foo.service.AppInitialiser</listener-class>
    </listener>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>

The configuration for FooWS is similar. Neither contains any mention of the application context so my expectation is that it should use /FooWS rather than default to /web.

The obvious solution would seem to be to override the context path in the web.xml but I can't find any way of doing this. Any suggestions?

Just some follow up, I accidentally changed the context path to /FooW. This time it deployed as expected to /FooW. Changing it back if /FooWS causes the old behaviour to return, that is, it deploys again to /web. It seems like I have a workaround for the moment.

For the benefit of anyone following this, I got the same behaviour with 3.1.2. I have now returned to 3.1 (b43) and it behaves as expected.

解决方案

Add a glassfish-web.xml file in the same folder as 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 error-url="">
    <context-root>/FooWS</context-root>
</glassfish-web-app>

这篇关于Glassfish 3.1.2.2上Web应用程序的上下文路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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