Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting user.dir system property in JBoss 5.1

 
Guy Roth
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Guy Roth
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Guy Roth
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic