1
votes

I am referencing a few resources from my Mule flow using the built in property ${dir.classes}

Like so:

<parse-template location="${dir.classes}/instruction.json.template" 
  doc:name="Parse Template"/>

The resource is found in the src/main/resources folder and the flow picks it up fine. However as soon as I want to add a properties file to the flow with this:

<context:property-placeholder location="integration.properties" />

Suddenly the flow can't find ${dir.classes} anymore and I get this error:

    Caused by: org.mule.api.config.ConfigurationException: Invalid bean definition 
      with name 'instructionFlow1' defined in null: Could not 
      resolve placeholder 'dir.classes' in string value 
      "${dir.classes}/instruction.json.template"
      (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)
        at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:52)
        at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
        at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:84)
        at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:207)

It looks like the properties file is hiding the default definition of ${dir.classes}. Unfortunately the ${dir.classes} property is not well documented by MuleSoft and there's no indication of what to do about this. The only option I've come up with is to reference my resources with explicit, physical paths, which is not ideal.

1

1 Answers

1
votes

Had this same problem yesterday! As soon as you use spring property placeholder then the syntax ${} resolves to properties in that property file.

This is somewhat annoying if you were using one the mule built vars however all is not lost.

If using maven anything in src/main/resource is just available to mule as this is where it looks for files to start with.

so just specify file path like:

<parse-template location="instruction.json.template" doc:name="Parse Template"/>