File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes How To: Path of JBoss Server deployment folder ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How To: Path of JBoss Server deployment folder !" Watch "How To: Path of JBoss Server deployment folder !" New topic

How To: Path of JBoss Server deployment folder !

Prathamesh Gaddam
Ranch Hand

Joined: Feb 18, 2008
Posts: 58
Hi ,

Using I want to retreive ( the specific files, from JBoss Server deployment folder. For example, following are the paths of deployed project. Using I want to get the fles from the directory ..\layout\templates\.

Please suggest how can I do this dynamically i.e the should get the folder path (\layout\templates) depending on its ( or FileRetriever.class) location. It needs to be irrespective of location of JBoss Server Installation. Is there any altenative using web.xml or component.xml files.

Thank you in advance !


- JBossServerPath: e:\jboss-4.2.1.GA\

- IntendedDirectoryPath: e:\jboss-4.2.1.GA\server\default\deploy\my.war\layout\templates

- FileRetriever.class (.class file which retrives files from templates directory) Path:

- path:
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

See these JBoss system properties which you can access by a call to System.getProperty(...)

[My Blog] [JavaRanch Journal]
Prathamesh Gaddam
Ranch Hand

Joined: Feb 18, 2008
Posts: 58
Thank you for the reply.

I tried to test, using JBoss properties, the path of JBoss server installation as:

. Is it the right way? Please guide further.

However, the value is printed as null. (I need the location of WEB-INF folder from the JBoss server).

Note: I m using the JBoss server vide Eclipse IDE with Seam Framework.
Peter Johnson

Joined: May 14, 2008
Posts: 5852


System.out.println("JBoss Home: "+System.getProperty("jboss.home.url"));

On the page Jaikiran cited, the bulleted text is the the system property name, the text in the light background is the default value.

JBoss In Action
Peter Johnson

Joined: May 14, 2008
Posts: 5852

I guess I should have read your post a little further. To access your WEB-INF folder, I suggest placing a properties file at WEB-INF/classes, and then in your servlet doing:

URL url = Thread.currentThread().getContextClassloader().findResource("");

The url will be the full path to the properties file, from there you should be able to find the full path for the WEB-INF directory.
Prathamesh Gaddam
Ranch Hand

Joined: Feb 18, 2008
Posts: 58
Thank you, Peter !

The workout

gave the value as


However the path where my xxxx.template.xhtml files deployed, are at

E:\Softwares\jboss-4.2.1.GA\server\default\deploy\UI.war\layout in templates folder.

I need the path so that my can dynamically load the list of xxxx.templates.xhtml, irrepective of location of JBOss server installed.

Is there any other way such as registering the path in any of the web.xml, seam.xml or jboss.xml?

I'm a newbie unaware of the relation between URL and actual directory path, and how they are used. Please guide me towards the first messagse of this post.
Roshan Qureshi

Joined: Aug 26, 2011
Posts: 1
Hi Prathmesh,

You can use following code in any jsp or servlet.

String serverPath= getServletContext().getRealPath("/");
This will give you full path of the server from root directory to your web application directory.
For me its: " D:\local\tomcat-6.0.29\webapps\myapp " when I sys out from myapp application.

Once you got the whole real path for the server system as above you can get the path relative to your directory.
So if I have some data file in myapp\data - I can get it appending \data\filename to the serverPath which we got earlier.
This will work in all situation even you have multiple servers installed on the same system.

Hope this will work for you.
Roshan Qureshi
CYGNEX Technologies
I agree. Here's the link:
subject: How To: Path of JBoss Server deployment folder !
It's not a secret anymore!