Spring Link to a circular placeholder when running an executable jar

When I tried to run the jar executable, I ran into the Circular Placeholder reference exception problem. Here is a detailed exception.

org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'postProcessProperties' defined in class path resource [applicationContext.xml]: Circular placeholder reference 'processor.core.poolsize' in property definitions [echo] at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:287) [echo] at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75) [echo] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663) [echo] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638) [echo] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407) [echo] at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) [echo] at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83) [echo] at com.autodesk.postprocess.engine.PostProcessEngine.start(PostProcessEngine.java:39) [echo] at com.autodesk.postprocess.engine.PostProcessEngine.main(PostProcessEngine.java:29) 

This is a spring application that uses an external properties file to read values ​​at startup. Here is the definition of spring. So far this has worked very well.

 <bean id="propertyConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_NEVER" /> <property name="ignoreResourceNotFound" value="true" /> <property name="locations"> <list> <value>classpath:/postprocess.properties</value> </list> </property> <property name="properties"> <props> <prop key="processor.core.poolsize">${processor.core.poolsize}</prop> <prop key="processor.max.poolsize">${processor.max.poolsize}</prop> </props> </property> </bean> <bean id="postProcessProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="processor.core.poolsize">${processor.core.poolsize}</prop> <prop key="processor.max.poolsize">${processor.max.poolsize}</prop> <prop key="processor.polling.delay">${processor.polling.delay}</prop> <prop key="processor.polling.period">${processor.polling.period}</prop> </property> </bean> 

I am using a shadow plugin to create a jar file. Here is a fragment

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.7.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.test.postprocess.engine.PostProcessEngine</mainClass> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> <filters> <filter> <artifact>:</artifact> <excludes> <exclude>META-INF/.SF</exclude> <exclude>META-INF/.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin> 

I'm not sure what causes this problem, as I used to use a similar pattern in other jar executables.

Any pointer would be appreciated.

thanks

+7
source share
3 answers

It is probably late to answer this, but to add it in the interests of someone who is facing a similar problem.

I was able to fix this by changing the key names. eg.

  <prop key="processor.core.poolsize">${processor.core.poolsize}</prop> <prop key="processor.max.poolsize">${processor.max.poolsize}</prop> 

Has been changed to something like

 <prop key="processor.core.poolsize">${core.poolsize}</prop> <prop key="processor.max.poolsize">${max.poolsize}</prop> 

the property filler key and the property value key to be filtered cannot be the same.

+8
source

He probably cannot find the resource - postprocess.properties . You can delete this line -

 <property name="ignoreResourceNotFound" value="true" /> 

Then, if the resource was not found, a corresponding message should be displayed.

0
source

I had the same problem when trying to run a spring integration test using SpringJUnit4ClassRunner. I did not know how to load the properties file, and after several incorrect steps, I found the @TestPropertySource annotation, which allowed me to determine the necessary property files.

I already tried @PropertySource before this and it doesn't work when you run the spring integration tag like this.

Hope this helps someone else.

0
source

All Articles