I'm using Mule 3 to query a database using JDBC, and I'd like to modify the query depending on input from a .properties file. I have this in my xml...
<context:property-placeholder location="C:\path\to\file\settings.properties" />
Getting the following exception...
Exception in thread "main" org.mule.module.launcher.DeploymentInitException: SAXParseException: The prefix "context" for element "context:property-placeholder" is not bound.
Do I need to include some special .xsd file?
The most optimal way to read a Mule properties file from a flow is using the ${Key} expression. This approach will work well for reading data from a Mule app properties file. Here, we first have to store the data in the Mule app properties file, as shown below, and then we have to use the “Key” to read the value.
properties is a file extension for files mainly used in Java-related technologies to store the configurable parameters of an application. They can also be used for storing strings for Internationalization and localization; these are known as Property Resource Bundles.
Add the xmlns namespace prefix and schema location to your Mule config mule element tag.
Prefix:
xmlns:context="http://www.springframework.org/schema/context"
SchemaLocation:
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
It should look like as below.
Eg:
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.3/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.3/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
<context:property-placeholder location="C:/path/to/file/settings.properties" />
........... Other stuff
</mule>
I had the same issues and fixed it. Here what I did.
Keeping all the files in classpath was a challenge. So Goto your project folder, Open .classpath file in text pad and add the below line
< classpathentry
including="file.dev.properties|file.prod.properties|file.stage.properties"
kind="src" path="src/main/resources"/ >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With