5 Replies Latest reply on Nov 19, 2011 4:04 AM by kennardconsulting

    Configure JBoss pre-processing of XML configuration files

    kennardconsulting

      Hi guys,

       

      JBoss appears to have some kind of non-standard (but cool!) facility for pre-processing XML configuration files. You can do...

       

      <someProperty>${foo:bar}</someProperty>
      

       

      ...and it will replace it with either 'bar' or the value from the '-Dfoo' command line parameter (if any).

       

      This appears to extend to configuration files within my own app, such as ejb-jar.xml and web.xml. But it does *not* appear to work in all places. For example if I do...

       

      <transport-guarantee>${web.transport.guarantee:NONE}</transport-guarantee>
      

       

      ...then I get...

       

        org.xml.sax.SAXException: cvc-enumeration-valid: Value '${web.transport.guarantee:NONE}' is not facet-valid with respect to enumeration '[NONE, INTEGRAL, CONFIDENTIAL]'. It must be a value from the enumeration.

       

      What is this pre-processing facility called? Where can I find more information about it? And can I configure it?

       

      Regards,

       

      Richard.

        • 1. Re: Configure JBoss pre-processing of XML configuration files
          kennardconsulting

          Answering my own question: this is handled by JBossXB and is configured in /all/deployers/metadata-deployer-jboss-beans.xml

           

          • 2. Re: Configure JBoss pre-processing of XML configuration files
            alesj

            Replacement should also work in web.xml, since it's JBossXB - as you figured it out - that handles all XML parsing.

            Did you manage to turn it on (if it's actually configurable?)?

            • 3. Re: Configure JBoss pre-processing of XML configuration files
              kennardconsulting

              Ales,

               

              Thanks for replying.

               

              Yes, I got it sort of working. However it appears to be a bug (or at least a problem in the design) in JBossXB. Specifically: JBossXB appears to validate the schema *before* doing any propertyRef replacements. This is probably because it is using Xerces with schema validation turned on.

               

              However sometimes the schema enumerates valid values for a field. In the case of web.xml's 'transport-guarantee', such values are NONE and CONFIDENTIAL. But they are *not* ${foo:NONE}.

               

              So trying to put a dynamic property ref in some parts of web.xml will fail. It will also fail for other schemas that enumerate valid values. It would be nice to find a solution to this?

               

              Regards,

               

              Richard.

              • 4. Re: Configure JBoss pre-processing of XML configuration files
                jaikiran

                Richard Kennard wrote:

                 

                 

                Yes, I got it sort of working. However it appears to be a bug (or at least a problem in the design) in JBossXB. Specifically: JBossXB appears to validate the schema *before* doing any propertyRef replacements. This is probably because it is using Xerces with schema validation turned on.

                 

                However sometimes the schema enumerates valid values for a field. In the case of web.xml's 'transport-guarantee', such values are NONE and CONFIDENTIAL. But they are *not* ${foo:NONE}.

                 

                I don't think that's the case. My guess is that you are setting the value of that system property via some *-service.xml file? Which might mean that the system property is not yet set when the web.xml is parsed and hence value not substituted. Something along these lines http://community.jboss.org/message/367141#367141. That's just a guess though. The real question is how and when are you setting the value for that "foo" system property?

                • 5. Re: Configure JBoss pre-processing of XML configuration files
                  kennardconsulting

                  Jaikiran,

                   

                  I'm actually not setting the 'foo' property all. But as I understand that shouldn't matter. The JBossXB syntax is:

                   

                       ${foo:NONE}

                   

                  So if I don't set 'foo' it should default to NONE. But it appears this happens too late in the cycle, because ${foo:NONE} will never pass schema validation.

                   

                  Regards,

                   

                  Richard.