ejb-jar.xml无法读取standalone.xml中定义的系统属性

时间:2014-08-12 23:00:54

标签: jms jboss7.x ejb-3.0 jboss-mdb

     <?xml version="1.0" encoding="UTF-8"?>  
     <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"  
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
                        http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"  
      version="3.0"  
       >  
  <enterprise-beans>  
    <message-driven>  
        <ejb-name>MyMDB</ejb-name>  
        <ejb-class>  
            com.foo.MyMDB  
        </ejb-class>  
        <messaging-type>javax.jms.MessageListener</messaging-type>  
        <transaction-type>Container</transaction-type>  
        <activation-config>  
            <activation-config-property>  
                <activation-config-property-name>  
                    destinationType  
                </activation-config-property-name>  
                <activation-config-property-value>  
                    javax.jms.Queue  
                </activation-config-property-value>  
            </activation-config-property>  
            <activation-config-property>  
                <activation-config-property-name>  
                    destination  
                </activation-config-property-name>  
                <activation-config-property-value>  
                    ${jms.queue.mymdb}  
                </activation-config-property-value>  
            </activation-config-property>  
            <activation-config-property>  
                <activation-config-property-name>  
                    useJNDI  
                </activation-config-property-name>  
                <activation-config-property-value>  
                    false  
                </activation-config-property-value>  
            </activation-config-property>                  
            <activation-config-property>  
                <activation-config-property-name>  
                    channel  
                </activation-config-property-name>  
                <activation-config-property-value>  
                    ${jms.queue.manager.channel}  
                </activation-config-property-value>  
            </activation-config-property>                  
            <activation-config-property>  
                <activation-config-property-name>  
                    hostName  
                </activation-config-property-name>  
                <activation-config-property-value>  
                    ${jms.queue.manager.host}  
                </activation-config-property-value>  
            </activation-config-property>                  
            <activation-config-property>  
                <activation-config-property-name>  
                    queueManager  
                </activation-config-property-name>  
                <activation-config-property-value>  
                    ${jms.queue.manager.name}  
                </activation-config-property-value>  
            </activation-config-property>                  
            <activation-config-property>  
                <activation-config-property-name>  
                    port  
                </activation-config-property-name>  
                <activation-config-property-value>  
                    ${jms.queue.manager.port}  
                </activation-config-property-value>  
            </activation-config-property>                  
            <activation-config-property>  
                <activation-config-property-name>  
                    transportType  
                </activation-config-property-name>  
                <activation-config-property-value>  
                    CLIENT  
                </activation-config-property-value>  
            </activation-config-property>                  
        </activation-config>  
    </message-driven>  
    </enterprise-beans>  
  </ejb-jar>  

以上是我的ejb-jar.xml文件。

以下内容来自standalone-full.xml

    <system-properties>  
          <!-- JMS properties for ejb-jar.xml -->  
           <property name="jms.queue.manager.channel"  value="QUEUE_MANAGER_CHANNEL"/>  
           <property name="jms.queue.manager.host"     value="QUEUE_MANAGER_HOST"/>  
           <property name="jms.queue.manager.name"     value="QUEUE_MANAGER_NAME"/>  
           <property name="jms.queue.manager.port"     value="QUEUE_MANAGER_PORT"/>  
           <property name="jms.queue.mymdb"            value="MYMDB_QUEUE"/>  
     </system-properties>  

但是当我部署MDB或在使用MDB后重新启动服务器时,它会产生错误,即ejb-jar.xml无法读取目标,hostName等的值。他们是空的。 我使用的是JBOSS 7.2.0。

我也确保使用standalone.bat -c standalone-full.xml启动jboss,因为我在这里放置了系统属性。

1 个答案:

答案 0 :(得分:0)

确保您的standalone-full.xml已启用spec-descriptor-property-replacement。此属性使jboss能够替换ejb-jar.xml等描述符中的属性值。

该物业位于

<subsystem xmlns="urn:jboss:domain:ee:1.1">
        <spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
        <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
</subsystem>

有关详细信息,请查看http://blog.akquinet.de/2012/11/21/property-substitution-of-deployment-descriptor-in-eap6-and-jboss-as7/