users@glassfish.java.net

Re: Static Content in Glassfish

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Thu, 08 Mar 2007 10:08:39 -0800

Hi Jesse,

glassfish_at_javadesktop.org wrote On 03/08/07 05:01 AM,:

>I am using Glassfish v2 Build 33 and I tried adding a virtual directory mapping by following http://blogs.sun.com/jluehe/entry/new_support_for_virtual_directory
>
>Thus far I have been unsuccessful but I just wanted to clear a few things up before I went totally insane. My goal is to have my app load static content that is stored locally on my harddrive which is seperate from the WAR.
>
>For example, I am storing XML docs locally at /srv/xml that I would like to be able to load from my application by going to "http://localhost:8080/xml-docs/" (i.e. http://localhost:8080/xml-docs/foo.xml). Via the admin console, I added a property named "alternatedocroot_1" with the value of "from=/xml-docs/* dir=/srv/xml" to the virtual server named "server".
>
>After a restart of Glassfish, shouldn't I be able to access the XML file by going to http://localhost:8080/xml-docs/foo.xml? Am I heading in the right direction? Or am I way off?
>
>
You've got it exactly right.

Now, there are several reasons why your alternate docroot setting may
not be picked up:

(1) You have a webapp deployed at "/", or

(2) You have a webapp deployed at "/someroot", and your virtual server
has declared this
      webapp as its default-web-module, meaning this webapp will not
only serve requests
      for "/someroot", but also "/".

In either case, the virtual server's docroot and alternate docroot
settings are being "shadowed"
by the webapp, and will be "resurrected" as soon as the webapp in (1) is
undeployed, or
the webapp in (2) is no longer declared as the virtual server's
default-web-module.

Does any of the above apply to your configuration?

Notice that support for alternate docroots is currently limited to
virtual servers.
The only reason for this limitation is that we currently have no way of
specifying
alternate docroots in a sun-web.xml. Internally, alternate docroots are
implemented
on our webmodule implementation class (we create a "dummy" webmodule off
a virtual
server's docroot), so once we've figured out a way to specify alternate
docroots
in sun-web.xml, we can remove this limitation without any implementation
changes.

Also notice that as of the just promoted GlassFish V2 b38, alternate
docroots may be
added/removed/reconfigured without requiring any server restart. This is
reflected
by the following unit test:

   
/cvs/glassfish/appserv-tests/devtests/web/virtualServerAlternateDocrootDynamicReconfig

Hope this helps.


Jan

>Any help is greatly appreciated, Jesse
>[Message sent by forum member 'manbeast7' (manbeast7)]
>
>http://forums.java.net/jive/thread.jspa?messageID=206833
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>