<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=garpinc" rel="nofollow">Keith Garry Boyce</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1076?redirect=false" rel="nofollow">SPR-1076</a></strong> and commented</p>
<p dir="auto">The call to getBean(factoryProcessorNames[i]) is flawed because it then must go out to get dependencies just to do  ordering.. Below is an example where I had a problem. And below is a work around.. I think rather than implement order perhaps you might want to add an attribute to bean definition i.e: order= and use that instead.</p>
<p dir="auto">What was happening is that to find the order of ConfigurationPlaceholderProcessor it had to satisfy dependency jconfigBean. The placeholder in that bean was supposed to be replaced first by propertyPlaceholderConfigurer so even though it gets the order for ConfigurationPlaceholderProcessor it's then to late to instantiate jconfigBean with appropriate placeholder from the propertyPlaceholderConfigurer since it had already been instantiated.</p>
<p dir="auto">--------- flawed code -------</p>
<p dir="auto">for (int i = 0; i &lt; factoryProcessorNames.length; i++) {<br>
if (Ordered.class.isAssignableFrom(getType(factoryProcessorNames[i]))) {<br>
orderedFactoryProcessors.add(getBean(factoryProcessorNames[i]));<br>
}<br>
else {<br>
nonOrderedFactoryProcessorNames.add(factoryProcessorNames[i]);<br>
}<br>
}</p>
<p dir="auto">------------- Here is where I had problem ------------</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean id=&quot;jmxExporter&quot;
    class=&quot;org.springframework.jmx.export.MBeanExporter&quot;&gt;
    &lt;property name=&quot;beans&quot;&gt;
        &lt;map&gt;

            &lt;entry key=&quot;Configuration:name=jmxConfig&quot;&gt;
                &lt;ref local=&quot;jconfigBean&quot; /&gt;
            &lt;/entry&gt;
        &lt;/map&gt;
    &lt;/property&gt;
&lt;/bean&gt; 

&lt;bean id=&quot;jconfigBean&quot; class=&quot;org.jconfig.jmx.ConfigHandler&quot;&gt;
    &lt;property name=&quot;resourceName&quot;&gt;
        &lt;value&gt;${config.filename}&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;configurationName&quot;&gt;
        &lt;value&gt;jmxConfig&lt;/value&gt;
    &lt;/property&gt;
&lt;/bean&gt;


&lt;bean id=&quot;configurationFactory&quot;
            class=&quot;org.reactive.configuration.JConfigConfigurationFactory&quot;
            singleton=&quot;true&quot;&gt;

	&lt;property name=&quot;fileName&quot;&gt;&lt;value&gt;jmxConfig&lt;/value&gt;&lt;/property&gt;
&lt;/bean&gt;


&lt;bean id=&quot;configuration&quot;
        factory-bean=&quot;configurationFactory&quot;
        factory-method=&quot;getConfiguration&quot; 
        depends-on=&quot;jmxExporter&quot;
        /&gt;
         
&lt;bean id=&quot;configurationPlaceholderProcessor&quot;
            class=&quot;org.reactive.beans.factory.config.ConfigurationPlaceholderProcessor&quot;&gt;
    &lt;property name=&quot;placeholderEvaluator&quot;&gt;
        &lt;bean class=&quot;org.reactive.beans.factory.config.jconfig.JConfigPlaceholderEvaluator&quot;&gt;
            &lt;property name=&quot;configuration&quot;&gt;
                &lt;ref bean=&quot;configuration&quot;/&gt;
            &lt;/property&gt;
        &lt;/bean&gt;
    &lt;/property&gt;
     &lt;property name=&quot;order&quot;&gt;
     	&lt;value&gt;2&lt;/value&gt;
     &lt;/property&gt;
&lt;/bean&gt;

&lt;bean id=&quot;propertyPlaceholderConfigurer&quot; class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt; 
   &lt;property name=&quot;properties&quot;&gt; 
      &lt;props&gt; 
         &lt;prop key=&quot;config.filename&quot;&gt;dev_config.xml&lt;/prop&gt;            
      &lt;/props&gt; 
   &lt;/property&gt; 
   &lt;property name=&quot;systemPropertiesModeName&quot;&gt; 
      &lt;value&gt;SYSTEM_PROPERTIES_MODE_OVERRIDE&lt;/value&gt; 
   &lt;/property&gt; 
   &lt;property name=&quot;order&quot;&gt;
     	&lt;value&gt;1&lt;/value&gt;
     &lt;/property&gt;
&lt;/bean&gt; "><pre class="notranslate"><code class="notranslate">&lt;bean id="jmxExporter"
    class="org.springframework.jmx.export.MBeanExporter"&gt;
    &lt;property name="beans"&gt;
        &lt;map&gt;

            &lt;entry key="Configuration:name=jmxConfig"&gt;
                &lt;ref local="jconfigBean" /&gt;
            &lt;/entry&gt;
        &lt;/map&gt;
    &lt;/property&gt;
&lt;/bean&gt; 

&lt;bean id="jconfigBean" class="org.jconfig.jmx.ConfigHandler"&gt;
    &lt;property name="resourceName"&gt;
        &lt;value&gt;${config.filename}&lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="configurationName"&gt;
        &lt;value&gt;jmxConfig&lt;/value&gt;
    &lt;/property&gt;
&lt;/bean&gt;


&lt;bean id="configurationFactory"
            class="org.reactive.configuration.JConfigConfigurationFactory"
            singleton="true"&gt;

	&lt;property name="fileName"&gt;&lt;value&gt;jmxConfig&lt;/value&gt;&lt;/property&gt;
&lt;/bean&gt;


&lt;bean id="configuration"
        factory-bean="configurationFactory"
        factory-method="getConfiguration" 
        depends-on="jmxExporter"
        /&gt;
         
&lt;bean id="configurationPlaceholderProcessor"
            class="org.reactive.beans.factory.config.ConfigurationPlaceholderProcessor"&gt;
    &lt;property name="placeholderEvaluator"&gt;
        &lt;bean class="org.reactive.beans.factory.config.jconfig.JConfigPlaceholderEvaluator"&gt;
            &lt;property name="configuration"&gt;
                &lt;ref bean="configuration"/&gt;
            &lt;/property&gt;
        &lt;/bean&gt;
    &lt;/property&gt;
     &lt;property name="order"&gt;
     	&lt;value&gt;2&lt;/value&gt;
     &lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; 
   &lt;property name="properties"&gt; 
      &lt;props&gt; 
         &lt;prop key="config.filename"&gt;dev_config.xml&lt;/prop&gt;            
      &lt;/props&gt; 
   &lt;/property&gt; 
   &lt;property name="systemPropertiesModeName"&gt; 
      &lt;value&gt;SYSTEM_PROPERTIES_MODE_OVERRIDE&lt;/value&gt; 
   &lt;/property&gt; 
   &lt;property name="order"&gt;
     	&lt;value&gt;1&lt;/value&gt;
     &lt;/property&gt;
&lt;/bean&gt; 
</code></pre></div>
<p dir="auto">------------- Here is possible (not ultimate) fix -----------<br>
for (int i = 0; i &lt; factoryProcessorNames.length; i++) {<br>
if (Ordered.class.isAssignableFrom(getType(factoryProcessorNames[i]))) {<br>
MutablePropertyValues values = getBeanFactory().getBeanDefinition(factoryProcessorNames[i]).getPropertyValues();<br>
int order = Integer.MAX_VALUE;<br>
if (values != null) {<br>
PropertyValue orderValue = values.getPropertyValue("order");<br>
if (orderValue != null) {<br>
String orderInt = (String) orderValue.getValue();<br>
if (orderInt != null) {<br>
order = new Integer(orderInt).intValue();<br>
}<br>
}<br>
}<br>
OrderedFactoryHolder factoryProcessorHolder = new OrderedFactoryHolder(factoryProcessorNames[i],order);<br>
orderedFactoryProcessorHolders.add(factoryProcessorHolder);<br>
}<br>
else {<br>
nonOrderedFactoryProcessorNames.add(factoryProcessorNames[i]);<br>
}<br>
}</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="private class OrderedFactoryHolder implements Ordered {
    
    
    /**
     * @param factoryName
     * @param order
     */
    public OrderedFactoryHolder(String factoryProcessorName, int order) {
        this.factoryProcessorName = factoryProcessorName;
        this.order = order;
    }
    private String factoryProcessorName;
    private int order;
    
    

    /**
     * @return Returns the factoryProcessorName.
     */
    public String getFactoryProcessorName() {
        return factoryProcessorName;
    }
    /* (non-Javadoc)
     * @see org.springframework.core.Ordered#getOrder()
     */
    public int getOrder() {
        return order;
    }
    
}"><pre class="notranslate"><code class="notranslate">private class OrderedFactoryHolder implements Ordered {
    
    
    /**
     * @param factoryName
     * @param order
     */
    public OrderedFactoryHolder(String factoryProcessorName, int order) {
        this.factoryProcessorName = factoryProcessorName;
        this.order = order;
    }
    private String factoryProcessorName;
    private int order;
    
    

    /**
     * @return Returns the factoryProcessorName.
     */
    public String getFactoryProcessorName() {
        return factoryProcessorName;
    }
    /* (non-Javadoc)
     * @see org.springframework.core.Ordered#getOrder()
     */
    public int getOrder() {
        return order;
    }
    
}
</code></pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.2.1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/10840/AbstractApplicationContext.java" rel="nofollow">AbstractApplicationContext.java</a> (<em>29.74 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/11845/EagerPropertyPlaceholderConfigurer.java" rel="nofollow">EagerPropertyPlaceholderConfigurer.java</a> (<em>3.85 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/11887/PlaceHolderOrderTest.zip" rel="nofollow">PlaceHolderOrderTest.zip</a> (<em>1.72 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398060141" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/6019" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/6019/hovercard" href="https://github.com/spring-projects/spring-framework/issues/6019">#6019</a> One BeanFactoryPostProcessor can't modify definition of a 2nd that has yet to run (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">1 votes, 4 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=desmethans" rel="nofollow">Hans Desmet</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-6735?redirect=false" rel="nofollow">SPR-6735</a></strong> and commented</p>
<p dir="auto">When you use JDBC in the DAO layer a duplicate key violation that occurs when you insert a record or update a record<br>
is translated to a DuplicateKeyException, which is fine !</p>
<p dir="auto">When you use Hibernate in the DAO layer, a duplicate key violation is translated to the more general DataIntegrityViolationException,</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 GA</p>