2

I am using JBoss 5 and the system properties service to set some system properties my app (ear with war) needs. One of these is the name of the virtual host which is referenced in jboss-web.xml:

<jboss-web>
  <context-root>/</context-root>
  <virtual-host>${my.host.system.prop}</virtual-host>
  ...
  <depends>jboss:type=Service,name=SystemProperties</depends>
</jboss-web> 

Note the dependency on the SystemProperties service.

However on server startup my app loads before the system properties have been set. Redeploying by touching the ear sorts it out. Interestingly I can see from the log that the SystemProperties service does indeed load before my app is deployed.

Anyone have any ideas? I don't want to resort to setting the props in JAVA_OPTS if I can help it.

David Tinker
  • 9,383
  • 9
  • 66
  • 98
  • If possible, you can try moving the dependency up to encompass the whole EAR, rather than an individual WAR. – Asynkronos Jun 09 '11 at 18:44

2 Answers2

3

Where do you your SystemProperties mbean defined? I had similar problem with JBoss 4.2 and my problem was solved by placing mbean definition into conf/jboss-service.xml instead of placing it into deploy directory. It cause that SystemProperties mbean is loaded in jboss startup.

Only disadvantage of this solution is that you loose hot deployment ability of SystemProperties mbean.

0

Deploy your Systemproperties as an own SystempropertiesService, e.g. as File "myapp-properties-service.xml"

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<server>
<mbean code="org.jboss.varia.property.SystemPropertiesService"
    name="jboss:type=Service,name=myAppSystemProperties">

            <!-- relative path of server profile, 
                 comma separated list of propertyfiles-->
    <attribute name="URLList">
        ./conf/props/myapp-system.properties,./conf/props/myapp-otherstuff.properties
    </attribute>
</mbean>

Now make sure that the myAppSystemPropertiesService gets enabled before your application does. We solved this problem by putting its declaration into the "deployers"-dir instead of the "deploy"-dir. The services declared in "deployers" folder get deployed before those in "deploy". E.g:

jboss-5.1.0.GA/server/default/deployers/myapp-properties-service.xml
jboss-5.1.0.GA/server/default/props/myapp-system.properties
jboss-5.1.0.GA/server/default/props/myapp-otherstuff.properties
polemoser
  • 59
  • 6