Reputation: 1603
Hi I am working with Mule Standalone server and when i am deploying my application as a ZIP to Standalone server as mentioned in the Mule Website Deployment Structure. In my project structure i have one file inside
src/main/resources/myfolder/myfile.xml
.
When i am reading this file from Anypoint Studio using System.getProperty("user.dir")
it is working fine .
When i am reading deploying the same in Standalone server it is throwing file not found exception, because their System.getProperty("user.dir")
is returning till bin where file not exist \Java\MuleStandAlone\bin
.
So to deploy to Mule Standalone where i will place my files so that i can read.
Upvotes: 1
Views: 291
Reputation: 1603
I have tried the way as Ryan Carter mention in the answer works for me and reading path as a String instead of Stream that also works for me.
String path= MyClass.class.getClassLoader().getResource("myfolder/myfile.xml").getPath();
Upvotes: 0
Reputation: 11606
files under src/main/resources will be available from the classpath, so there should be no reason to lookup the root directory. Just read it from classpath as "myfolder/myfile.xml".
E.g:
<set-payload value="#[Thread.currentThread().getContextClassLoader().getResourceAsStream('myfolder/myfile.xml')]" />
Upvotes: 3