aspose file tools*
The moose likes JBoss/WildFly and the fly likes setting user.dir system property in JBoss 5.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "setting user.dir system property in JBoss 5.1" Watch "setting user.dir system property in JBoss 5.1" New topic
Author

setting user.dir system property in JBoss 5.1

Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
In JBoss 4.2.3 the System property 'user.dir' is defined to be

<JBoss-root>/bin


When I ran the same application on JBoss 5.1 I noticed that it cannot find the System property user.dir

why there is no default definition for version 5.1?
and how can I define it manually?
I followed this suggestion and added my property into properties-service.xml but it had no affect and still JBoss couldn't find the system:user.dir value.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

That property will by default be set by the JVM when you launch Java. It points to the user's current working directory.

When I ran the same application on JBoss 5.1 I noticed that it cannot find the System property user.dir


How, when and where are you accessing that property?

[My Blog] [JavaRanch Journal]
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
I am trying to call the System property from my web application that is deploayed as a .war in <JBoss root>/server/default/deploy

by calling:
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5830
    
    7

You can view all of the system properties in the jmx console (http://localhost:8080/jmx-console). Pick the jboss:type=Service,name=SystemProperties mbean, and the showAll operation.


JBoss In Action
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
1. I opened the Mbean SystemProperties and couldn't find an operation to show all the properties such as suggested 'showAll'
I found only: addChild, getEventType, mejbStartRecursive, mejbStart, mejbStop, removeChild

2. even if I could view the list of existing properties my question is in addition how can I modify and add my own system parameters to JBoss (apart from adding them to the java execution command with -D)
Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
Actually you are correct I did manage to perform System.getProperty("user.dir") and get the correct folder (bin)

however when I put in my web.xml the param:


and perform:


the returned value was user.dir/momo.ini
instead of bin/momo.ini

Why is that?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165



That's not how you are supposed to use it. The syntax is:



So when the xml is being parsed, JBoss will first look for a system property named "system-property-name" and if it's set then it will use that value. If it's not set then it will use the "default-value".

So you would want to change it to:

Guy Roth
Ranch Hand

Joined: Aug 09, 2009
Posts: 74
I works! Many thanks to you.


BTW, as far as I know the convention to use system param in web.xml using ${system:<param-name>} worked in JBoss 4.2.3.GA and stopped working only in JBoss 5.1, right?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: setting user.dir system property in JBoss 5.1