2011-06-09 52 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 
相关问题