2011-06-09 49 views
2

我正在使用JBoss 5和系統屬性服務來設置一些系統屬性,我的應用程序(包含war的耳朵)需要。其中之一是它在的jboss-web.xml中引用的虛擬主機的名稱: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> 

注意在SystemProperties服務的依賴性。

但是在服務器啓動時我的應用程序在設置系統屬性之前加載。通過觸摸耳朵進行重新部署將其分類。有趣的是,我可以從日誌中看到,在部署應用程序之前,SystemProperties服務確實會加載。

任何人有任何想法?我不想訴諸在JAVA_OPTS中設置道具,如果我可以幫助它的話。

+0

如果可能,您可以嘗試將依賴項移動到包含整個EAR,而不是單個WAR。 – Asynkronos 2011-06-09 18:44:55

回答

3

你在哪裏定義了你的SystemProperties mbean?我有類似的問題與JBoss 4.2和我的問題解決了將mbean定義到conf/jboss-service.xml而不是將其放置到部署目錄。它導致SystemProperties mbean被加載到jboss啓動中。

這個解決方案的唯一缺點是你鬆散SystemProperties mbean的熱部署能力。

0

將您的Systemproperties部署爲一個自己的SystempropertiesService,例如,爲文件「MYAPP - 屬性 - 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> 

現在確保您的應用程序不前myAppSystemPropertiesService被啓用。我們通過將其聲明放入「部署者」目錄來代替「部署」目錄來解決此問題。在「部署」文件夾中聲明的服務在「部署」之前部署。例如:

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 
相關問題