users@glassfish.java.net

Re: context-root not working

From: Hong Zhang <hong.hz.zhang_at_oracle.com>
Date: Tue, 17 Jul 2012 09:59:48 -0400

For an enterprise application (.ear), the
application.xml/glassfish-application.xml context root will be used (and
glassfish-web.xml ignored), if you want to override the context root in
application.xml, you should do it in glassfish-application.xml.

For a standalone web module (.war), you could use glassfish-web.xml to
override the default context root.

On 7/17/2012 5:15 AM, tomaz wrote:
> Environment:
> ----------------
> GlassFish Server Open Source Edition 3.1.2 (build 23)
> ----------------
>
> I try to change doc root of my web module(war) I use this deployment descriptor and seam nothing is working:
>
> 1) 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">
>
> <context-root>aris</context-root>
>
>
> 2) web.xml:
> ----------
> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
> version="3.0">
>
> <servlet>
> <servlet-name>container</servlet-name>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>container</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
>
> 3) application.xml:
> -------------------
> <!DOCTYPE glassfish-application PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Java EE Application 6.0//EN"
> "http://glassfish.org/dtds/glassfish-application_6_0-1.dtd">
>
> <web>
> <web-uri>aris</web-uri>
> <context-root>aris</context-root>
> </web>
>
>
> And it is not working, what I'm doing wrong?
>
>
> PS: If I deployed war from web admin console and change Context Root it works and glassfish write to domain.xml:
> <application context-root="/aris" location="${com.sun.aas.instanceRootURI}/applications/aris-api-server-1.0-SNAPSHOT/"
> name="aris-api-server-1.0-SNAPSHOT" object-type="user">
>
> Is there any different way to achieve this, not when deploying from web console?
>
>
> Regards, Tomaz