Set System Properties In Jboss

Set System Properties In Jboss explains about how to set the system properties in JBoss Application Server.

In your web application, some times situation arises that you need to set the system properties from JBoss properties file.

In this example, I am going to show how to read the uploaded folder from properties file inside JBoss application server.

JBoss AS 7

If you are using JBoss AS 7, you need to define these properties into following configuration file.

If you are working on Standalone mode, the file is located in the folder [/home/user/jboss-eap-6.2/standalone/configuration/standalone.xml]
If you are working on Domain mode, the file is located in the folder [/home/user/jboss-eap-6.2/domain/configuration/domain.xml]

Below configuration file, I need to set system properties as upload.dir=/home/uploads, here we are specifying key,value pairs. Please check below example configuration

<?xml version='1.0' encoding='UTF-8'?>

<server xmlns="urn:jboss:domain:1.5">

    <extensions>
        <extension module="org.jboss.as.clustering.infinispan"/>
        <extension module="org.jboss.as.connector"/>
        <extension module="org.jboss.as.deployment-scanner"/>
        <extension module="org.jboss.as.ee"/>
        <extension module="org.jboss.as.ejb3"/>
        <extension module="org.jboss.as.jaxrs"/>
        <extension module="org.jboss.as.jdr"/>
        <extension module="org.jboss.as.jmx"/>
        <extension module="org.jboss.as.jpa"/>
        <extension module="org.jboss.as.jsf"/>
        <extension module="org.jboss.as.logging"/>
        <extension module="org.jboss.as.mail"/>
        <extension module="org.jboss.as.naming"/>
        <extension module="org.jboss.as.pojo"/>
        <extension module="org.jboss.as.remoting"/>
        <extension module="org.jboss.as.sar"/>
        <extension module="org.jboss.as.security"/>
        <extension module="org.jboss.as.threads"/>
        <extension module="org.jboss.as.transactions"/>
        <extension module="org.jboss.as.web"/>
        <extension module="org.jboss.as.webservices"/>
        <extension module="org.jboss.as.weld"/>
    </extensions>
    <system-properties>
        <property name="upload.dir" value="/home/uploads"/>
    </system-properties>
........................................................................................
........................................................................................
</server>

JBoss AS 4/JBoss AS 5/JBoss AS 6

If you are using above JBoss versions, you need to add properties into properties-service.xml. It is availabe inside "/deploy/properties-service.xml". If it is not available, you need create one and add the following details.

<server>
<mbean code="org.jboss.varia.property.SystemPropertiesService" 
     name="jboss:type=Service,name=SystemProperties">

    <!-- 
       | Load properties from each of the given comma seperated URLs
    -->
    <attribute name="URLList">
      /apps/ourapp/ourapp.properties
    </attribute>

    <!-- 
       | Set raw properties file style properties.
    -->
    <attribute name="Properties">
	upload.dir=/home/uploads
    </attribute>
  </mbean>
</server>

How to set System Properties in JBoss

Below example we are going to read the properties file, it is already configured in JBoss Application Server

Required Libraries

You need to download

  1. JDK 7
  2. Eclipse 4.2
  3. JBoss 6.2

1 2 Next





Your email address will not be published. Required fields are marked *