1 2 Previous Next 18 Replies Latest reply on May 10, 2013 9:22 PM by knarayanan123

    The replacement of system properties in *-ds.xml is done only for elements of string value type

    rhanus

      synopsis

      • enterprise application deployed in jboss-5.1
      • would like to use <max-pool-size>${myapp.db.maxPoolSize}</max-pool-size> in myapp.ear/my-ds.xml
      • ends up with maxPoolSize == 0

      story behind

      I encountered this problem while staging my ear from devel to loadtests and then production usage
      I had an idea I would use a parameter for max-pool-size attribute and set it in accompanying property-service.xml so that I would have one deployment and several property-service.xml files based on target environment but it ends up with zero value of maxPoolSize

       

      I have searched the forum as well as issue tracker and found this problem as unresolved:

      suggested solution

      having some spare time during christmas I dived into connector source codes and hopefully found a non-invasive way how to solve it

       

      all magic is done in ManagedConnectionFactoryParserDeployer.parse() and it's matter of JAXB definitelly

      I suggest to define specific @XmlJavaTypeAdapter adapters for non-string "primitive" fileds (int, long, boolean, Boolean) of ManagedConnectionFactoryDeploymentMetaData

      These adapters in their unmarsal methods would call StringPropertyReplacer.replaceProperties() in accordance with PropertyEditorManager.findEditor()

      I tried to implement such a fix and it works for me but didn't run against testsuite yet

       

      BTW quick look at source codes for 6.0 final and prety sure there is the same problem

        • 1. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
          jeff.zhang

          https://issues.jboss.org/browse/JBAS-8344?page=com.atlassian.jira.plugin.ext.subversion:subversion-commits-tabpanel#issue-tabs

          Please fetch latest branch_5_1 and try it.

           

          And it also apply some code patch into AS 6 Final, It could handle String type.

          • 2. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
            rhanus

            wow so the implementation is here as I suggested :-) I really didn't take notice of subversion commits in the issue

             

            it took me a while to build JBPAPP_5_1 on windoze without patch utility because simply setting build.unsecure= in build.properties is not enought

            but that's a different story

             

            ok your fix is working but only for integer and long fields of ManagedConnectionFactoryDeploymentMetaData and its succesors

            why not booleans ?

             

            while trying to apply your fix I encounter following problem:

            • in a separate deploy dir I have myapp.ear and myprops-service.xml where the property myapp.db.maxPoolSize is defined
            • descriptor myapp.ear/my-ds.xml is parsed by JAXB before myprops-service.xml is fully deployed so that myapp.db.maxPoolSize is not a system property when trying to replace it

            I don't see a way how to define the dependency to the property service in myapp.ear/my-ds.xml, datasources/local-tx-datasource/depends simply cannot help in that case

            • 3. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
              jaikiran

              Radim Hanus wrote:

               


              while trying to apply your fix I encounter following problem:

              • in a separate deploy dir I have myapp.ear and myprops-service.xml where the property myapp.db.maxPoolSize is defined
              • descriptor myapp.ear/my-ds.xml is parsed by JAXB before myprops-service.xml is fully deployed so that myapp.db.maxPoolSize is not a system property when trying to replace it

              I don't see a way how to define the dependency to the property service in myapp.ear/my-ds.xml, datasources/local-tx-datasource/depends simply cannot help in that case

              http://community.jboss.org/message/367141

              • 4. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                rhanus

                Thanks for hint!

                 

                I want to maintain single jboss installation as well as single deployment and several versions of myprops-service.xml. So I rejected placing property service into conf/jboss-service.xml.

                I tried to define <depends>jboss:type=Service,name=MyAppSystemProperties</depends> dependency to:

                • ManagedConnectionFactoryParserDeployer in jboss-jca.deployer
                • JBossAppParsingDeployer in ear-deployer-jboss-beans.xml

                but no success. What did I wrong ?

                • 5. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                  rhanus

                  I also played a bit with supply/demand mc feature but still no sucess

                  I walked through trace logs and I think this is connected with general deployer's architecure: metadata object are instanced by jaxb when main deployer parses deployments and obviously it's not good idea to depends on mail deployer

                  • 6. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                    alesj

                    How exactly are you seeing the "but no success"?

                     

                    As the deployers are again just plain beans in MC/AS,

                    so same "service" sort of functionality applies.

                     

                    It just might be an issue of missing dependency,

                    as we check for completness after each phase: boot, deployers/ and deploy/.

                    Placing your property service into deployers/ should work.

                    • 7. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                      rhanus

                      Hi Ales

                       

                      Thanks for answer!

                       

                      >> How exactly are you seeing the "but no success"?

                      I've rewritten properties-service.xml to properties-jboss-bean.xml to be able to define supply:

                       

                      <bean name="SystemProperties" class="org.jboss.varia.property.SystemPropertiesService">                  <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:type=Properties,name=MyAppSystemProperties",exposedInterface=org.jboss.varia.property.SystemPropertiesServiceMBean.class</annotation>                  <property name="properties" replace="false">            

                                 myapp.db.maxPoolSize=150
                                myapp.db.idleTimeout=60
                           </property>
                           <supply>SystemProperties</supply>
                      </bean>

                       

                      and I placed demand into ear CL deployer:

                       

                      <bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">
                           <!-- A flag indicating if ear deployments should have their own scoped
                              class loader to isolate their classes from other deployments.
                           -->
                           <property name="isolated">false</property>

                           <demand>SystemProperties</demand>
                      </bean>

                       

                      but JAXB started to unmarshal ds descriptor before "configured" of system properties

                      may be I'm completely wrong but as I had some time during christmas to dive into source codes I'm really curious about solution :-)

                       

                      >> Placing your property service into deployers/ should work.

                      and it really works !!!

                      • 8. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                        alesj
                        >> Placing your property service into deployers/ should work.

                        and it really works !!!

                        Cool. :-)

                        Anything else?

                        • 9. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                          rhanus

                          yeah great thanx again

                           

                          >> Anything else?

                          why the usage of supply/demand above doesn't wotk ?

                          • 10. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                            alesj
                            >> Anything else?

                            why the usage of supply/demand above doesn't work ?

                            Didn't you use this at the end?

                            • 11. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                              rhanus

                              No

                              when myproperties-jboss-beans.xml are placed in deployers dir they are available before the ear gets deployed

                              ok it finally works somehow :-)

                               

                              I supposed to use the supply/demand scenario with both myproperties-jboss-beans.xml and myapp.ear in deploy dir but it doesn't work since JAXB unmarshals myapp.ear/my-ds.xml descriptor before SystemPropertiesService reaches its configured state and thus

                              • would like to use <max-pool-size>${myapp.db.maxPoolSize}</max-pool-size> in myapp.ear/my-ds.xml
                              • ends up with maxPoolSize == 0

                               

                              2011-01-03 14:45:56,810 DEBUG (main)[org.jboss.system.ServiceConfigurator] MaxSize set to 0 in jboss.jca:service=ManagedConnectionPool,name=Ora11DS

                              • 12. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                                alesj

                                Ah, now I actually see/understand your problem -- at least I think so. :-)

                                 

                                My previous suggestion is wrong.

                                What you need is the following, in theory at the moment.

                                * deployment myapp.ear must depend on SystemPropertiesService, but in PARSE stage

                                ** this way ear' -ds.xml will be parsed with required system properties

                                 

                                We already have proper mechanism in place for this,

                                see jboss-dependency.xml (http://community.jboss.org/wiki/JBoss5custommetadatafiles),

                                but it will need minor adjustments.

                                 

                                See dependency-deployers-jboss-beans.xml in deployers/,

                                all three jboss-dependency.xml related deployers need a change of stage.

                                 

                                <property name="stage">DeploymentStages.PRE_PARSE</property> <--- pseudo code

                                 

                                Then adding proper jboss-dependency.xml into ear' META-INF should do the trick.

                                • 13. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                                  rhanus

                                  I tried my best but it still doesn't work for me please help ;-)

                                   

                                  fixed deployers/dependency-deployers-jboss-beans.xml

                                  <bean name="DependenciesParserDeployer" class="org.jboss.deployers.vfs.plugins.dependency.DependenciesParserDeployer">
                                      <property name="stage"><inject bean="PreParseStage"/></property>
                                    </bean>
                                  <bean name="DependenciesMDDeployer" class="org.jboss.deployers.vfs.plugins.dependency.DependenciesMetaDataDeployer">
                                      <property name="stage"><inject bean="PreParseStage"/></property>
                                  </bean>
                                  <bean name="DeploymentDependenciesDeployer" class="org.jboss.deployers.vfs.plugins.dependency.DeploymentDependencyDeployer">
                                      <property name="stage"><inject bean="PreParseStage"/></property>
                                  </bean>

                                  <bean name="PreParseStage" class="org.jboss.deployers.spi.deployer.DeploymentStage">
                                      <constructor>
                                        <parameter class="java.lang.String">PreParse</parameter>
                                        <parameter class="java.lang.String">Not Installed</parameter>
                                      </constructor>
                                  </bean>

                                   

                                  new deploy/myapp.ear/META-INF/jboss-dependency.xml:

                                  <dependency xmlns="urn:jboss:dependency:1.0">
                                    <item whenRequired="PreParse" dependentState="Create">istep:type=Properties,name=SystemProperties</item>
                                  </dependency>

                                   

                                  I've tried a plenty of both whenRequired and dependentState combinations but no luck

                                  • 14. Re: The replacement of system properties in *-ds.xml is done only for elements of string value type
                                    alesj
                                    I tried my best but it still doesn't work for me please help ;-)

                                    I've tried a plenty of both whenRequired and dependentState combinations but no luck

                                    Good attempt, seriously!

                                     

                                    You need to change this:

                                     

                                    <item whenRequired="PreParse" dependentState="Create">istep:type=Properties,name=SystemProperties</item>

                                     

                                    whenRequired cannot be PreParse, as we're there right now - when parsing - hence already past it.

                                    Change it to Parse. And you can drop the dependantState attribute, by default it should be Installed, which is fine.

                                     

                                    Let me know if this works then.

                                    Otherwise I'll give it a try. ;-)

                                    1 2 Previous Next