2

I cannot find a proper way to add a directory to my app context on jboss 6. I'll use this mapping for static content. Can someone give me a hand on that?

skaffman
  • 381,978
  • 94
  • 789
  • 754
user659510
  • 21
  • 1
  • 2
  • can you not add the directory to the deployment archive or can you not read the files within the archive? – ThomasRS Mar 14 '11 at 22:14
  • In fact I have static content like photos in a file server. This file server share is mapped in the jboss server as a directory... Obviously this directory is out of my app context. So I gotta map this external directory to the app context... I can do it well on tomcat 6... but I cannot do the same in jboss 6 yet. – user659510 Mar 14 '11 at 22:43
  • see http://community.jboss.org/message/531424 and http://community.jboss.org/message/531424 for similar issues, I'd try to unpack the .war and map the target directory (a second time (?)) to the root or subdirectory of the resulting directory (web application). – ThomasRS Mar 14 '11 at 23:06

3 Answers3

3

There are no more 'virtual directories' in JBoss 6. Apparently this went out with JBoss 5. The only available options I've found are:

  1. create a blank /WEB-INF/web.xml (so like just <web-app/>) in your static content directory and make a symlink with a .war extension in your jboss deploy directory. You can also copy the directory containing the static content to your deploy directory, but I find a symlink much more useful.
  2. create a webapp with a servlet that serves static content from a configured directory (discussed here)
  3. if you're using a web framework like spring mvc 3, you can use the 'resources' feature to serve content for you (discussed here)
Community
  • 1
  • 1
lakemalcom
  • 886
  • 1
  • 7
  • 17
0

The bad news is that you can serve static content only inside JBoss applications. The good news is that it is very easy to transform any folder into an application folder.

The easiest solution is to copy all your static content into your server\default\deploy\ROOT.war directory.

A more complex solution is the following.

  • Copy the ROOT.war folder in the position where you want to put your static content.

  • Rename ROOT.war into any name you like but it must end with .war, for instance my_static_content.war.

  • Put all your static content into that directory.

  • Enable external deploy to the folder that contains your static content folder. External deploy with JBoss 6 and JBoss 5

  • Restart JBoss

  • Your content will be into the URI http:\\localhost:8080\my_static_content\. You have to specify the exact name of the files that you want to serve, because directory listing is not allowed.

Vitaly Olegovitch
  • 3,185
  • 5
  • 28
  • 47
0

this thread helped me get static content in an external directory served up on jboss eap 5.1 without the use of links and without moving or renaming the ROOT.war folder.

note that you still have to create a directory structure that tricks jboss into serving up your content. it's not as easy as adding a <Context> child element to the <Host name="localhost"> in the server.xml file. it seems like a hack but at least it works.

Eric S.
  • 320
  • 2
  • 10