aspose file tools*
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
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
Author

How To: Path of JBoss Server deployment folder !

Prathamesh Gaddam
Ranch Hand

Joined: Feb 18, 2008
Posts: 58
Hi ,

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

Please suggest how can I do this dynamically i.e the FileRetriever.java should get the folder path (\layout\templates) depending on its (FileRetriever.java 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 !

PATHS:

- 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:
E:\jboss-4.2.1.GA\server\default\deploy\my.war\WEB-INF\dev\org\domain\my\session

- FileRetriever.java path:
E:\jboss-4.2.1.GA\server\default\deploy\my.war\WEB-INF\classes\org\domain\myl\session
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10213
    
166

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
author
Bartender

Joined: May 14, 2008
Posts: 5837
    
    7

Close:

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
author
Bartender

Joined: May 14, 2008
Posts: 5837
    
    7

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("xxx.properties");

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

file:/E:/MyWorkspace/UI/build/classes/components.properties

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 FileRetriever.java 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
Greenhorn

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.
Regards,
Roshan Qureshi
CYGNEX Technologies
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How To: Path of JBoss Server deployment folder !